https://kotlinlang.org logo
#compose
Title
# compose
v

Vitaliy Zarubin

05/30/2021, 12:30 PM
Please tell me how to add the addOnDestinationChangedListener correctly
j

jossiwolf

05/30/2021, 2:06 PM
Yeah, with the first variant the
apply
block will get called in every composition which you don't want. Use a
DisposableEffect
with the
NavController
as
key
like in Chris' example
🙏 1
i

Ian Lake

06/01/2021, 6:55 PM
I'd strongly recommend switching to the
currentBackStackEntryFlow
in Navigation 2.4.0-alpha01 and collecting on that in a `LaunchedEffect`: https://developer.android.com/reference/androidx/navigation/NavController#currentBackStackEntryFlow()
🙏 1
1
3 Views