I am seeing that a couple people make their view m...
# compose
a
I am seeing that a couple people make their view models to expose the entire UI state thru a single property like a
val state: State<UiState>
. Is that a good practice? I am concerned about the granularity of the recompositions. Suppose that only one property of
UiState
changes, and that that property is consumed by only a single composable. Would only that composable face recomposition, or would the entire screen since
state
is the only
State<T>
object in the composable tree ?
c
I always just expose state as a regular class with a bunch of inner snapshot state. gives me the granualrity i need. and way better than the copy boielerplate you get with stateFlow
d
Copy boilerplate isn't too bad with Arrow Optics btw...
c
gotta try that out
There's also Kopykat for a lighter solution: https://github.com/kopykat-kt/kopykat
😍 1