flatMapFirst

fun <T, R> Flow<T>.flatMapFirst(block: suspend (first: T, upstream: Flow<T>) -> Flow<R>): Flow<R>(source)

Applies the given suspend lambda function to the first emitted value of the original flow and the entire original flow, producing a new flow of type R.

Return

A new flow of type R emitted by the given lambda function.

Parameters

block

The suspend lambda function to be applied to the first emitted value of the original flow and the original flow. The lambda function takes two parameters: the first emitted value of the original flow and the original flow itself. The lambda function should return a flow of type R.


fun <T, R> Flow<T>.flatMapFirst(block: suspend (first: T) -> Flow<R>): Flow<R>(source)

Subscribes to the upstream and when it receives the first element calls block and then emits the returned Flow