Ravi
05/18/2021, 11:12 PMlifecycleIsResumed
check is added to discard duplicated navigation events. Is this change required as I've followed similar pattern?Ian Lake
05/18/2021, 11:43 PMIan Lake
05/18/2021, 11:44 PMIan Lake
05/18/2021, 11:45 PMnavigate()
). Obviously for something like Owl which doesn't track analytics, etc., the approach shown there is enoughRavi
05/18/2021, 11:53 PMexactly once
from ViewModel and these actions are getting invoked through LaunchedEffect
snapshotFlow
inside compose. With this approach lifecycleIsResumed
check required ?Ian Lake
05/19/2021, 12:00 AMDESTROYED
), so if you want to only process events when resumed, you'd want to use repeatOnLifecycle(Lifecycle.State.RESUMED)
inside your LaunchedEffect
ala https://kotlinlang.slack.com/archives/CJLTWPH7S/p1615397085281600?thread_ts=1615395535.277500&cid=CJLTWPH7SRavi
05/19/2021, 12:04 AMrepeatOnLifecycle
ty
val sideEffectFlow = remember(mainSideEffect, lifecycleOwner) {
mainSideEffect.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.RESUMED)
}
LaunchedEffect(sideEffectFlow) {
sideEffectFlow.collect {
when (it) {
is Navigate.ChatScreen -> action.navigateChatScreen(it.imageUrl)
}
}
}
Ian Lake
05/19/2021, 12:05 AM