Any recommendation to pass a `State` & `Side-E...
# orbit-mvi
m
Any recommendation to pass a
State
&
Side-Effect
to a Composable screen, instead of passing the
ViewModel
?
ViewModel
ref based on: https://github.com/orbit-mvi/orbit-sample-stocklist-jetpack-compose/blob/main/app/[…]otlin/org/orbitmvi/orbit/sample/stocklist/list/ui/ListScreen.kt Code in 🧵 1️⃣ , 2️⃣ or 3️⃣ ?
b
1️⃣ 2️⃣ : I don't like the idea of passing the container to my composables, as it tight them to Orbit which isn't a good thing. Wether you pass a Container or a ContainerHost is roughly the same thing 3️⃣ Not sure where that
snapshotFlow
comes from what about 4️⃣ : Passing a
state: StateFlow
and a
sideEffect: Flow
?
today i learned 1
🙏 1
m
the 4️⃣ approach seems nice, as loosely coupled from both Orbit-MVI & Android ViewModel this ways.
👍 1
b
I wouldn't call
launch
in LaunchedEffect, as you're already in a coroutine
🙏 1
today i learned 1
✍️ 1
a
Why pass the state flow when you can simply pass an UpdateEmailState? Side effects in compose are a funny one. Take a bottom sheet for example, the way compose is setup you are probably better off this being part of the state flow. It's worth reading https://proandroiddev.com/sending-view-model-events-to-the-ui-eef76bdd632c and Google's updated documentation.
🙏 1
m
thanks, our first try was to use
UpdateEmailState
directly, until we implement side-effect