emitAll

suspend fun <T> FlowCollector<T>.emitAll(channel: ReceiveChannel<T>)(source)

Emits all elements from the given channel to this flow collector and cancels (consumes) the channel afterwards. If you need to iterate over the channel without consuming it, a regular for loop should be used instead.

Note, that emitting values from a channel into a flow is not atomic. A value that was received from the channel many not reach the flow collector if it was cancelled and will be lost.

This function provides a more efficient shorthand for channel.consumeEach { value -> emit(value) }. See consumeEach.


suspend fun <T> FlowCollector<T>.emitAll(flow: Flow<T>)(source)

Collects all the values from the given flow and emits them to the collector. It is a shorthand for flow.collect { value -> emit(value) }.