consumeEach

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

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

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

Performs the given action for each received element.

WARNING: It is planned that in the future a second invocation of this method on an channel that is already being consumed is going to fail fast, that is immediately throw an IllegalStateException. See this issue for details.

The operation is terminal. This function consumes all elements of the original ReceiveChannel.