inline suspend fun <E> ReceiveChannel<E>.consumeEach(action: (E) -> Unit)(source)

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)(source)

Deprecated (with error)

BroadcastChannel is deprecated in the favour of SharedFlow and is no longer supported

Subscribes to this BroadcastChannel and performs the specified action for each received element.

Note: This API is obsolete since 1.5.0 and deprecated for removal since 1.7.0