consume

inline fun <E, R> BroadcastChannel<E>.consume(
    block: SubscriptionReceiveChannel<E>.() -> R
): R
(source)

Platform and version requirements: JVM

Opens subscription to this BroadcastChannel and makes sure that the given block consumes all elements from it by always invoking cancel after the execution of the block.

inline fun <E, R> ReceiveChannel<E>.consume(
    block: ReceiveChannel<E>.() -> R
): R
(source)

Platform and version requirements: JVM

Makes sure that the given block consumes all elements from the given channel by always invoking cancel after the execution of the block.