hey folks, bit of a weird issue and I’m not sure w...
# compose
o
hey folks, bit of a weird issue and I’m not sure what is the best way to go about it. in a compose screen i can have this, simple flow collection with lifecycle STARTED
Copy code
val lifecycleOwner = LocalLifecycleOwner.current
val navigationEventFlowLifecycleAware = remember(viewModel.navigationEventFlow, lifecycleOwner) {
    viewModel.navigationEventFlow.flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
}
i have a bottomsheet that opens a url, and user comes back when this is resumed, the view sends an intent to the viewmodel
Copy code
LifecycleResumeEffect(Unit) {
     viewModel.intent(Intent.CheckAgain)
     onPauseOrDispose {}
}
and the viewmodel then decides to close by sending an event to that flow but the screen doesnt close because the flow is found to not be collecting yet, what is strange to me, is the flow is supposed to be collecting when lifecycle is STARTED, which happens before RESUMED, so technically this all should work any suggestions please
z
Might be a race condition that the effect that causes the VM to send closed is dispatched before the effect that collects is dispatched.
o
that is what i suspect, but looking at it broadly, it seems like
Copy code
flowWithLifecycle(lifecycleOwner.lifecycle, Lifecycle.State.STARTED)
doesn’t necessarily guarantee the flow will start collecting then, and in my case it starts collecting much after RESUME state