flattenConcatEager

fun <T> Flow<Flow<T>>.flattenConcatEager(concurrency: Int = DEFAULT_CONCURRENCY, bufferSize: Int = Channel.BUFFERED): Flow<T>(source)

Flattens the given flow of flows into a single flow in a sequential manner, without interleaving nested flows. But unlike flattenConcat collecting nested flows performed concurrently with a given concurrency limit on the number of concurrently collected flows.

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

Operator fusion

Applications of flowOn, buffer, and produceIn after 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.

bufferSize

hints about the number of expected values from each inner Flow. Should be either a positive channel capacity or one of the constants defined in Channel. If Flow tries to emit more than bufferSize values before being concatenated to output, then it will be suspended