Open nickstamp93 opened 4 years ago
@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.
}
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?