unorderedFlatMapIterableAsync
Applies the given transformation function transform to each value of the original Flow and emits the results. The processing of items in the flow is concurrent and limited by concurrency level. Each transformed value is then flattened and emitted individually.
The result flow may emit the elements in an unordered manner, which makes this function faster than flatMapIterableAsync.
Example usage:
flowOf(1, 2, 3)
.unorderedFlatMapIterableAsync(2) { listOf(it, it + 1) }
.collect { println(it) } // Prints the results in an unordered manner
Return
A new flow with the transformed and flattened items.
Parameters
The maximum number of concurrent transformations.
The transformation function to apply to each item.
Applies the given transformation function transform to each value of the original Flow and emits the results. The concurrency is managed by an AsyncSemaphore created by the semaphore suspending function. Each transformed value is then flattened and emitted individually.
The result flow may emit the elements in an unordered manner, which makes this function faster than flatMapIterableAsync.
Example usage:
val customSemaphore: suspend CoroutineScope.() -> AsyncSemaphore = { AsyncSemaphore(this, 2) }
flowOf(1, 2, 3)
.unorderedFlatMapIterableAsync(customSemaphore) { listOf(it, it + 1) }
.collect { println(it) } // Prints the results in an unordered manner
Return
A new flow with the transformed and flattened items.
Parameters
The suspending function that creates an AsyncSemaphore.
The transformation function to apply to each item.