jean
05/21/2021, 4:42 AMAs a rule of thumb, you should create a view model to hold your state […] when the composable is close to the root of the screen.
When that’s not the case, for examples, composables that are reusables […], don’t use a view model , instead create a regular state holder class to manage state and expose events.This is said shortly after 7:32 in the video, the slide at that time refers to a
Carousel
and a ExpandableCard
but I couldn’t find any related code in the compose-sample project. Does anyone hasve a concrete/sharable example of such a “regular state holder class”?
Albert Chang
05/21/2021, 4:49 AMremember*State()
functions are state holder classes, e.g. ScaffoldState
, LazyListState
, etc.jean
05/21/2021, 8:19 AMAlbert Chang
05/21/2021, 8:23 AMSean McQuillan [G]
05/21/2021, 8:37 PMSean McQuillan [G]
05/21/2021, 8:38 PMSean McQuillan [G]
05/21/2021, 8:39 PMjean
05/21/2021, 8:44 PMjean
05/21/2021, 8:44 PM