flattenMerge

fun <T> Flow<Flow<T>>.flattenMerge(concurrency: Int = DEFAULT_CONCURRENCY): Flow<T>

Flattens the given flow of flows into a single flow with a concurrency limit on the number of concurrently collected flows.

If concurrency is more than 1, then inner flows are be collected by this operator concurrently. With concurrency == 1 this operator is identical to flattenConcat.

Operator fusion

Applications of flowOn, buffer, and produceInafter this operator are fused with its concurrent merging so that only one properly configured channel is used for execution of merging logic.

When concurrency is greater than 1, this operator is buffered by default and size of its output buffer can be changed by applying subsequent buffer operator.

Parameters

concurrency

controls the number of in-flight flows, at most concurrency flows are collected at the same time. By default it is equal to DEFAULT_CONCURRENCY.

Sources

common source
Link copied to clipboard