Skip to content
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

Get result or callback from destination #5

Open
nickstamp93 opened this issue Oct 8, 2019 · 1 comment
Open

Get result or callback from destination #5

nickstamp93 opened this issue Oct 8, 2019 · 1 comment

Comments

@nickstamp93
Copy link

Let's say i have a destination (bottom sheet, fragment) that adds a new item in the repository. How should i get a callback or a results from it?

@hamedsilver
Copy link

hamedsilver commented Mar 26, 2020

@nickstamp93 in new version of navigation you can pass data back to your previous destination this feature added in 2.3.0-alpha03
you can send data from destination B like this:
navController.previousBackStackEntry?.savedStateHandle?.set("key", result)
and get data in destination A like this:

    navController.currentBackStackEntry?.savedStateHandle?.getLiveData("key")?.observe(
        viewLifecycleOwner) { result ->
        // Do something with the result.
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants