Tim Malseed
03/21/2023, 12:04 AMLaunchedEffect
to perform one-off navigation events, based on state. So, for example, if the current viewState
is Unauthorized
, I might use a LaunchedEffect
to call navigateToLoginScreen()
But, let’s say there are two of these launched effects, with two possible navigation destinations. I’ve noticed an issue where, if the viewState
updates and triggers a navigation event - the viewState
can again update before that navigation transition is complete - triggering yet another navigation event. This means my navigation can end up in an unexpected state.
Is there a way to ensure a LaunchedEffect is cancelled before the composition leaves the tree (like, during a navigation transition)?Ben Trengrove [G]
03/21/2023, 1:08 AMIan Lake
03/21/2023, 3:19 AMRESUMED
is enough, see the previous time we discussed this: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1677626180373409?thread_ts=1677626180.373409&cid=CJLTWPH7STim Malseed
03/21/2023, 3:19 AMIan Lake
03/21/2023, 3:22 AMTim Malseed
03/21/2023, 3:22 AM