produceIn

@FlowPreview fun <T> Flow<T>.produceIn(
    scope: CoroutineScope
): ReceiveChannel<T>
(source)

Creates a produce coroutine that collects the given flow.

This transformation is stateful, it launches a produce coroutine that collects the given flow and thus resulting channel should be properly closed or cancelled.

A channel with default buffer size is created. Use buffer operator on the flow before calling produce to specify a value other than default and to control what happens when data is produced faster than it is consumed, that is to control backpressure behavior.