Does Compose have a concept like Flutter’s Provide...
# compose
k
Does Compose have a concept like Flutter’s Provider classes? It would be nice to provide and instance of a class at a high level and easily retrieve it at a lower level
s
There is. Look into CompositionLocal
k
Looks interesting. I read that recommend not using them if possible. What about ViewModels or state that is used in multiple places?
w
We’ve quite successfully used a MVVM architecture where multiple view models may use the same singleton instances of models. In the models we store state as `MutableStateFlow`s that are exposed through read-only `StateFlow`s with setter functions for updating values.
In the end, the view models subscribe to the same
StateFlow
and react to updates accordingly