Hello everyone, coming from Flutter community and ...
# android
h
Hello everyone, coming from Flutter community and Want to ask a Question. Is there any State management package / and what is the recommended way to store your state, for easy access and management? ( we have things like BLoC / providers / State containers ) is that the same for kotlin or using remember { mutable state of() } is the recommended approach?
😶 2
k
If you're developing only for Android, you'll want to go with MVVM or MVI with official Android components such as
ViewModel
, they couple well together with Compose, in this scenario Compose is only a UI framework, the data layer is separated you could even use the same code to create UI specific to Wear OS or Android TV. An alternative to the official guidance would be Molecule, that could be potentially used for Compose Multiplatform as well if I'm not mistaken.
p
Try googling/chat-gpting State Management in Android or State Management in Jetpack compose Android or State Management in compose UI? You probably gonna get richer information than a response here
k
I was wondering the same thing. MVVM is more of an architecture that a state management package. After reading several things about needing to be careful about state in compose, something other than just using remember everywhere would be nice
p
I did not want to comment since it is not specific to Kotlin but I agree on not abusing remember. I prefer hosting the state outside the Composable. Be it a ViewModel in jetpack navigation Navbackstackentry or a component in a solution like decompose.
c
Jetpack compose has remember stuffs for keeping views' state. and data classes for data. And this is MVI just like Flutter, I think. Non-jetpack compose users use MVVM pattern in common and it has ViewModel to keep the state and also bundle stuffs to keep the data even in the app crash.
👍 1
t
I think this user is talking about redux style state managememt. Which is not how android normally has it implemented. I’m sure you can find lobs but best to stick with the platform standards
a
You can check out Decompose for BLoC-like architecture - https://github.com/arkivanov/Decompose And MVIKotlin for MVI state management - https://github.com/arkivanov/MVIKotlin They both multiplatform in case you ever want to support other platforms.
👍 2