withLatestFrom

fun <T, U, R> Flow<T>.withLatestFrom(other: Flow<U>, transform: suspend (T, U) -> R): Flow<R>

Combines each upstream value with the latest value of other through transform.

Upstream values that arrive before other has emitted are dropped. Emissions of other alone never produce output; only the upstream drives emissions. A failure in either flow fails the resulting flow.


fun <T, U> Flow<T>.withLatestFrom(other: Flow<U>): Flow<Pair<T, U>>

Pairs each upstream value with the latest value of other.

Upstream values that arrive before other has emitted are dropped.