consumeEach
inline suspend fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit)
Content copied to clipboard
Performs the given action for each received element and cancels the channel after the execution of the block. If you need to iterate over the channel without consuming it, a regular for
loop should be used instead.
The operation is terminal. This function consumes all elements of the original ReceiveChannel.
inline suspend fun <E> BroadcastChannel<E>.consumeEach(action: (E) -> Unit)
Content copied to clipboard
Subscribes to this BroadcastChannel and performs the specified action for each received element.
Note: This API will become obsolete in future updates with introduction of lazy asynchronous streams. See issue #254.