Vincent Williams08/13/2020, 8:11 PM
streetsofboston08/13/2020, 8:18 PM
for that. It is like a StateFlow with respect that it is a hot stream of data, but it differs that it is state-less (a new collector will not receive the last value it had emitted). Think of a StateFlow like it could've been backed by a Conflated Broadcast Channel and of an EventFlow like it could've been backed by a rendezvous Channel.
Vincent Williams08/13/2020, 8:19 PM
streetsofboston08/13/2020, 8:37 PM
. But you risk loosing an emission if no one is listening/collecting (but then it wouldn’t be a problem… 🙂 )
Vincent Williams08/13/2020, 8:38 PM
streetsofboston08/13/2020, 8:40 PM
Vincent Williams08/13/2020, 9:15 PM
streetsofboston08/13/2020, 9:19 PM
in one background thread more than once in really quick succession. And your collector in the UI, on the Main thread (Main dispatcher), which should finish in 16ms, but is somehow a bit slower than the producer calling the
method for the 2nd time. Usually this is not a big issue, since Events are often used for navigation and two navigation events should not be emitted in such quick succession (faster than the UI can handle them).
method in the
for example (assuming here you do Android development). This way you won’t miss sent events (unless the
itself gets cancelled).
gildor08/13/2020, 11:48 PM
Vincent Williams08/13/2020, 11:51 PM
gildor08/13/2020, 11:52 PM
streetsofboston08/14/2020, 3:20 AM
on that channel would not risk losing any events, even if the consumer's CoroutineScope is cancelled (eg UI detached), because if the consumer (collector) is detached no one is listening and the sender/producer will just suspend until a new collector arrives (UI re-attached).
gildor08/14/2020, 3:37 AM