consume

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

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

The operation is terminal.


Deprecated (with error)

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

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.

Note: This API is obsolete since 1.5.0 and deprecated for removal since 1.7.0 It is replaced with SharedFlow.

Safe to remove in 1.9.0 as was inline before.