https://kotlinlang.org logo
#compose
Title
# compose
m

Marko Novakovic

08/12/2021, 4:44 PM
any ideas on how to prevent this double click navigation?
1
c

Colton Idle

08/12/2021, 4:47 PM
I'm probably misremembering/misrepresenting this, but I could have sworn that ian lake said that compose nav should make these sorts of double clicks impossible. hmm.
🤔 1
p

pepos

08/12/2021, 5:14 PM
how im handling this: • All user interaction with UI is emitting `UiEvent`s, the class that is receiving this
UiEvent
is broadcasting using
Flow
to whatever class is interested on the events • I have another class, lets say a navigation manager, that is listening for all the `UiEvent`s coming from UI user interaction, and decides when to perform the navigation action. This class knows that once X navigation is made, it doesn’t need to continue listening for those `UiEvent`s and just ignore the subsequent ones
a

Alex Vanyo

08/12/2021, 5:42 PM
One solution (I believe credited to Ian Lake) is checking if the current `NavBackStackEntry`’s
Lifecycle
is resumed, and if not resumed, disregard the request to navigate. Calling
navController.navigate
will synchronously update the
NavBackStackEntry
to no longer be resumed, which allows handling cases like this where multiple taps happen back-to-back.
❤️ 2
m

Marko Novakovic

08/12/2021, 6:10 PM
@pepos thank you for the suggestion. I has similar idea but it seems a bit off for my usecase
👍 1
@Alex Vanyo that is great. thanks
🎉 1
40 Views