How far do you typically go with pushing ui state ...
# compose
a
How far do you typically go with pushing ui state inside a viewmodel? I have a complicated composable with a lot of moveable elements in there, but I want the position changes to be animated. Should I solve this in the viewmodel or in the composable itself?
z
What I do is store my state in just a mutableStateOf
a
This is a fun architectural choice. I come from react JS land where the general rule of thumb is to hoist as much state as possible out of components. That being said I also have written an extensive JetPack compose app. There are, however some cases where it does make sense to have some internal component state… like if you where creating a widget that doesn’t need external state passed in, but in most of my projects I do a immutable state store using the redux pattern and have most if not all state live there. You can obviously do the same with view models. The only thing I’ll do in the component typically is formatting the data from the state… such as formatting date times and such. Again there is no hard rule, but this gives you some nice benefits… namely that testing your components in isolation becomes really easy when all state is taken out.