minimise
minimise copied to clipboard
Navigation doesn't occur unless the state has changed
StateFlow won't emit the same value twice. For example, if we enter a screen and then press the android back button (without using navigationManager), then we will not be able to navigate by the same route.
I was able to mitigate the issue using following changes:
// Instead of mutable state, I am using shared flow so that I can see duplicates
var commands = MutableSharedFlow<NavigationCommand>(
extraBufferCapacity = 1,
onBufferOverflow = BufferOverflow.DROP_OLDEST
)
// To support MutableSharedFlow
fun navigate(directions: NavigationCommand) {
commands.tryEmit(directions)
}
This is working for me properly. If there are some other better methods, I would like to know that also.
Thanks.