-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add navigation listener #132
Comments
You can use extensions in this case, see: Line 91 in b5610ca
|
Another option is smth liks val nc = rememberNavController(..)
LaunchEffect(nc.current){ // current is a state, so every time you navigate it will changed and call code below
trackScreen(nc.current)
}
... i may add smth to see if it was back or frorward navigation |
Ideally, I need to know both "from" and "to" screen, and both your suggestions allow to know the target destination only. Or am I missing smth? 🤔 |
both "from" & "to"... hmmm it might be a case... |
@BioRyajenka Some updates on fast solution, found in the notes "why dont we need nav listeners" var lastScreen by remember { mutableStateOf<NavDestination<*>?>(null) }
LaunchedEffect(navController.current) {
val currentScreen = navController.current
if(lastScreen != currentScreen){
// track from lastScreen to currentScreen
lastScreen = currentScreen
}
} You can combine it with |
That would work, thanks! |
Hi,
This is a request to add navigation listener to the lib.
I want to spawn analytics events on navigation and currently I do smth like:
But custom code is not convenient and having an ability to add listener would be great.
The text was updated successfully, but these errors were encountered: