Also, it seems that now in `alpha07` tapping a sel...
# compose
f
Also, it seems that now in
alpha07
tapping a selected bottom nav item again does nothing anymore. Isn't the expected behavior to reload that screen or am I wrong? If it isn't, how can I achieve this behavior?
i
In a reactive UI where your UI is entirely driven by data and state, what state do you expect to be changed when you aren't changing what your current tab is?
f
well I was expecting the call to
navigate
to do something
so how would you go about telling a bottom nav destination that it has been reselected?
passing down lambdas is probably not good
c
State isn't changing though, so it seems to work as I'd expect it IMO.
i
Generally, you'd pass down a Channel / Channel backed Flow for a your refreshEvents that a destination could LaunchedEffect+collect on and trigger your behavior. You'd just need to keep track of which tab is selected and use that to swap between your reselection behavior (sending an event to your Channel) vs triggering a NavController swap between back stacks
You still have the main problem of "what does refresh mean in a reactive UI based app" since the whole point is that your UI is always up to date with the latest state
f
@Ian Lake what I mean by reload is starting back at the top of a list
now I'm getting your initial question
@Ian Lake instead of keeping track of the current destination in a variable, could I check If the current destination matches the target route in the onClick method of the BottomNavigationItem?
i
Well, each bottom nav stack could have many destinations on it, so the current destination isn't necessarily the one you'd associate with your BottomNavigationItem
f
@Ian Lake right, forgot about that
@Ian Lake but don't I usually only care about the start destination of a bottom nav item on reselection?
i.e. if I'm not currently on that destination, navigate back to it
if I'm on that destination, scroll up
i
That would be entirely up to you. You're the one writing the code so you could have your onClick or your collection of refreshEvents do different things based on whatever logic you want
f
ok, thank you
so inside the onClick method I put a value into the channel
and then I pass that channel down to the Composables that need to react to reselection
I guess 1 channel is enough since the active destination will consume the value