I have a hard time deciding how to manage my state...
# multiplatform
k
I have a hard time deciding how to manage my state in KMM. My database layer exposes flows. And I usually handle logic inside of Android ViewModels. Is there a goto approach in KMM?
s
Not sure there's a goto approach, but I interface all my IO through a repository layer, then any business logic through the usecase layer under that. (All in common Kotlin code) My ViewModels are then implemented in Swift and Kotlin (in the android module) separately but are pretty dumb, all the important logic being in the common classes
m
I use similar approach. I implement code that would be in `ViewModel`(presentation) inside pseudo
ViewModel
and I call it
StateStore
and my Android
ViewModel
just delegates calls to
StateStore
, same for iOS version
m
You can have a look my viewmodels they are shared between iOS and Android, I use same state, effect , event and Datas for iOS and android: I called it as MVVM SEED but there is no article yet, it works really well for both platform so far, here is the repo: https://github.com/Oztechan/CCC
m
k
We have some internal docs explaining the logic behind the KaMP Kit viewmodel setup. There’s been a bunch of internal debate around how to do that. If I get fancy with docusaurus I’ll try to publish something not-internal 🙂
💯 4
👍 5
m
+1! I’d really love to see that
m
Having access to such an article would be a great resource for the community! Especially, since so many look at
KaMPKit
as a guideline to start with KMM. This is a topic that arises quite frequently and I’d personally be more than happy to see an established, documented, pattern arise. I guess this has already somwhat happened, thanks to
KaMPKit
, or at least that’s how I see the current state.
v
Try usingMokomvvm