https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
r

Rak

12/03/2021, 11:29 AM
Hi, I have a main screen that shows your status. You go off to other screens that update your status and then you return to the main screen. Problem is that I am not sure how to best refresh the status? No intents are firing on return (I think the last State is displayed but its no longer valid).
a

appmattus

12/03/2021, 2:11 PM
indeed, nothing will re-trigger on return you can possibly use
repeatOnSubscription
inside the
onCreate
block which is cancelled when there are no subscribers to either
state
or
sideEffect
flows and re-executed when there is at least one subscriber to either, if that makes sense. something like:
Copy code
val container = container<…>(initialState {
    repeatOnSubscription {
        // this will (re-)execute every time there is at least one active subscriber
        val result = lookupValue()
        reduce { copy(result = result) }
    }
}
today i learned 1
r

Rak

12/03/2021, 2:11 PM
I’ll try that, thanks!