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
SrSouza
07/06/2021, 3:14 AM
There is. Look into CompositionLocal
k
kevindmoore
07/06/2021, 4:04 AM
Looks interesting. I read that recommend not using them if possible. What about ViewModels or state that is used in multiple places?
w
Walter Berggren
07/06/2021, 6:30 AM
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.