Joaquín Vidal
04/29/2024, 2:45 PMviewModel.navigate.collect {
it?.let {
viewModel.onNavigated()
findNavController().popBackStack(R.id.home, false)
findNavController().navigate(it)
}
}
It works great, but I’m curious about why the navigation is executed if, once you execute the popBackStack, the current fragment should no longer exist. Is it a race condition? Or is it intentional that before killing the fragment, the current block of code is completed? Also, this is in a launch block, so when the onDestroy of the fragment is executed, the job gets cancelled.
If you need more info, putting a delay between one line and another (even just 1 ms) causes it to stop working, meaning it destroys the fragment. So I think that is something that happens on purpose.Phil Bayfield
04/29/2024, 6:44 PMpopUpTo
Joaquín Vidal
04/29/2024, 6:46 PMJoaquín Vidal
04/29/2024, 6:51 PMPhil Bayfield
04/29/2024, 6:54 PMnavigate
with popUpTo
calls popBackStack
internally 🤔Joaquín Vidal
04/29/2024, 6:55 PMPhil Bayfield
04/29/2024, 6:57 PMJoaquín Vidal
04/29/2024, 6:58 PM