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

Navigation doesn't occur unless the state has changed #40

Open
aleksandr-sudnikov-ext-orion opened this issue May 25, 2022 · 1 comment

Comments

@aleksandr-sudnikov-ext-orion

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.

@amank22
Copy link

amank22 commented Oct 16, 2022

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.

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