Teimatini Marin
09/06/2022, 10:51 PMFan-out
Multiple coroutines can receive from a single channel; however, to receive them properly we should use a for-loop (consumeEach is not safe to use from multiple coroutines)
I wonder if this statement regarding consumeEach is still accurate? In which sense it is not safe?Francesc
09/06/2022, 11:25 PMconsumeEach
, when the coroutine completes it will close the channel. That would affect the other coroutines that may still want to continue consuming from the channel, so I would think that's the reason.Teimatini Marin
09/06/2022, 11:34 PMFrancesc
09/06/2022, 11:38 PMconsumeEach
will do the clean-up when the consumer is done, but if you have multiple consumers you could launch them in the same scope and, when you're done with the processing, you can cancel the scope and release all the resources there. Not sure if this answers the question.Teimatini Marin
09/06/2022, 11:42 PM