Hi where have i made my mistake ? <https://stacko...
# compose
c
This has nothing to do with
snapshotFlow
.
LaunchedEffect
is restarting because of the configuration change. Put your snapshotFlow into your ViewModel and the problem should go away.
t
i tried refactoring snapshotFlow into my viewmodel and it didnt cure the issue 😞 not sure why
c
Can you show more code? How is your view model scoped?
t
Copy code
fun displayItem(context: Context) = viewmodelScope.launch {
snapshotFlow { displayItemState }
            .filter { it.viewIntent != null }
            .collectLatest { displayItemState ->
                context.startActivity(displayItemState.viewIntent)
            }
}
...something like that 😉
z
Seems like a code smell, having your context inside a ViewModel. Can’t help but think it’ll lead to issues. But I guess that’s not related to your problem