ParallelFlow

interface ParallelFlow<out T>

Base interface for parallel stages in an operator

Functions

collect
Link copied to clipboard
abstract suspend fun collect(vararg collectors: FlowCollector<T>)

Properties

parallelism
Link copied to clipboard
abstract val parallelism: Int

Extensions

concatMap
Link copied to clipboard
@ExperimentalCoroutinesApi()
fun <T, R> ParallelFlow<T>.concatMap(mapper: suspend (T) -> Flow<R>): ParallelFlow<R>
Maps the upstream value on each rail onto a Flow and emits their values in order on the same rail.
filter
Link copied to clipboard
fun <T> ParallelFlow<T>.filter(predicate: suspend (T) -> Boolean): ParallelFlow<T>
Filters the values of the upstream in parallel.
map
Link copied to clipboard
fun <T, R> ParallelFlow<T>.map(mapper: suspend (T) -> R): ParallelFlow<R>
Maps the values of the upstream in parallel.
reduce
Link copied to clipboard
fun <T, R> ParallelFlow<T>.reduce(seed: suspend () -> R, combine: suspend (R, T) -> R): ParallelFlow<R>
Reduces the source items into a single value on each rail and emits those.
@FlowPreview()
fun <T> ParallelFlow<T>.reduce(combine: suspend (T, T) -> T): Flow<T>
Reduce the values within the parallel rails and then reduce the rails to a single result value.
sequential
Link copied to clipboard
@FlowPreview()
fun <T> ParallelFlow<T>.sequential(): Flow<T>
Consumes the parallel upstream and turns it into a sequential flow again.
transform
Link copied to clipboard
fun <T, R> ParallelFlow<T>.transform(callback: suspend FlowCollector<R>.(T) -> Unit): ParallelFlow<R>
Transform each upstream item into zero or more emits for the downstream in parallel.