When collecting a flow using an activity lifecycleScope, I’ve noticed that using the default
CoroutineStart.Default
, doesn’t work sometimes when using an empty buffer
Channel
and
receiveAsFlow
(where an event is being offered instead of sent).
CoroutineStart.Undispatched
does seem to work however.
I’m assuming this is because the launched coroutine needs to have executed the collect coroutine before an event is offered to the channel, in order to receive it.
So, is using
CoroutineStart.Undispatched
the correct approach, or should I be using a buffered channel instead?