produceIn

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

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 produceIn 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.

Sources

common source
Link copied to clipboard