consumeEach

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

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.

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

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.

Note: This API will become obsolete in future updates with introduction of lazy asynchronous streams. See issue #254.