minimise icon indicating copy to clipboard operation
minimise copied to clipboard

Navigation doesn't occur unless the state has changed

Open aleksandr-sudnikov-ext-orion opened this issue 2 years ago • 1 comments

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.

amank22 avatar Oct 16 '22 12:10 amank22