Hello guys, when using voyager for navigation, how...
# multiplatform
b
Hello guys, when using voyager for navigation, how can we listen and receive on navigation changed
not kotlin but kotlin colored 1
p
I think for a library specific question you get a better chance by opening an issue/discussion in their public repo.
s
The Navigator it self is a SnapshotStack, you can listen to any property from navigator as a State.
For example LaunchedEffect(navigator.lastItem) will trigger every time the top screen changes
b
@SrSouza thanks, on another topic, how to share a viewModel between couple screens
s
There are some PRs to make that possible but we did not complete anything yet. In practice, what you can do is retrieving the ViewModel by using any non voyager ViewModelStoreOwner I think. For example
LocalContext.context.unwrapActivity
.
viewModel<YourScopedViewModel>(viewModelStoreOwner = LocalContext.context.unwrapActivity)
1