I have a viewmodel that receives flow as livedata from scenario
val state get () = syncScenario.state.asLiveData ()
In the activity, we subscribe to this livedata, some logic happens and used the activityResult
private val resultLauncher = registerForActivityResult (activityResult ()) {result ->
when (result.resultCode) {
Activity.RESULT_OK -> sync()
Activity.RESULT_CANCELED -> return
}
}
when we return, we have an observer triggered with the last state and the previous logic with navigation is performed again
private val syncStateObserver = Observer<StateInfo?> {
it?: return@Observer
when (it) {
is Guest -> doWhenUserIsGuest()
is Authorized -> doWhenUserIsAuthorized()
}
}
How can you ignore an observer trigger with the same value on return?