alsoTo

fun <E, S> Flow<E>.alsoTo(bufferCapacity: Int = Channel.BUFFERED, onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND, onUndeliveredElement: (E) -> Unit? = null, flow: Flow<E>.() -> Flow<S>): Flow<Pair<E, S>>

Allows the Flow to be collected and transformed into another Flow concurrently. The transformed Flow is collected asynchronously in the provided coroutineScope. The original flow and the transformed flow share the same buffer with the specified bufferCapacity, onBufferOverflow policy, and onUndeliveredElement handler.

Return

A Flow of the original items.

Parameters

bufferCapacity

The capacity of the shared buffer.

onBufferOverflow

The policy to apply when the buffer overflows.

onUndeliveredElement

The function to be invoked when an element cannot be delivered.

flow

The transformation function that maps the original flow to a new flow.