Yes. Absolutely- and as usual, you've helped me enter "A Compose State Of Mind".... Thank You for walking me through, as running through important steps is always a waste of time.
parts of this are useful, but many more are not explained enough or with real examples. very convoluted. hopefully the codelab will make stuff clearer.
Passing parameters to remember() (see code around 14:00) means that JetsnackAppState will be reset whenever any of its dependencies changes, right? It also won't survive configuration change or process recreation. Can lead to bugs if JetsnackAppState contains its own (not derived from dependencies) state.
Hi! Yeah, that's the idea, generally, you want to recreate the state holder if the dependencies change. If you don't do that, you might be using old instances of certain types that could potentially lead to memory leaks. As mentioned in your other comment, use `rememberSaveable` to make state survive config changes or process recreation
When LazyList's scroll position and expanded items are stored in CartState (19:09), they will be cleared on navigating to another screen & back, correct? That won't look good from UX perspective.
Hello! `collectAsState` is remembered and it's not re-executed on every recomposition. New values emitted into the flow will cause recompositions though. Hope this clarifies few things!
The composable function will only be recomposed when the collectAsState() value changes, Compose is smart enough to skip recomposing parts of the UI where the states did not change.
This doesnt seemed to follow OOP principle at all with all those remember keywords. It is a function that magically store state somewhere you dont know using remember keyword. Flutter does this cleanly with widget as object instead of function.
Compose is comparable to using XML / Data binding, UI frameworks do not benefit at all from object-oriented programming. I'm glad Google realized this and made Compose fully declarative. You might have a point with the "magic" remember keyword, but you do not have to use it, just can also put your state in a view model, it is only a convenience feature to make things simpler.
The code passed in the lambda to the remember function is executed only on initial composition, and not in re-composition, unless the any of the optional key parameters to the remember function have changed, which will cause the lambda to be re-executed.