Im having a bit of an odd problem with compose and data updates! For example, if I tap a button that creates some data that I then navigate to using its id; the current screen will update to reflect the new data before the transition to the new screen is done. This looks a bit quirky, kind of unexpected; the only solution that comes to mind is to somehow pause data updates during navigation .. but that doesnt really seem like a good idea. Any other ideas? 🙂
s
ste
09/03/2022, 1:05 PM
+1, same problem
i
Ian Lake
09/05/2022, 2:21 AM
collectAsStateWithLifecycle
takes a
Lifecycle.State
so you could set that to
RESUMED
(instead of its default
STARTED
) to avoid updating your state while the animation is running - the Navigation Component synchronously moves the state of a screen down to
STARTED
when you call
navigate
z
Zoltan Demant
09/05/2022, 5:52 AM
Interesting @Ian Lake, could you please point me to where that happens? I dont use the navigation component but I could use it as inspiration in my own setup 🙏🏽
Of course, the Navigation Component is probably doing more than you might need to do - it handles dialog destinations, subgraphs (that have their own Lifecycle that is the max of all of their children), reentrant calls to navigate, etc.
z
Zoltan Demant
09/05/2022, 3:25 PM
Thank you Ian! That looks complicated, but I think I get the gist of it and how I could make it work 🙏🏽