race

fun <T> race(flow1: Flow<T>, flow2: Flow<T>, vararg flows: Flow<T>): Flow<T>(source)

Mirrors the one Flow in an array of several Flows that first either emits a value or sends a termination event (error or complete event).

See also


Mirrors the one Flow in an Iterable of several Flows that first either emits a value or sends a termination event (error or complete event).

When you pass a number of source Flows to race, it will pass through the emissions and events of exactly one of these Flows: the first one that sends an event to race, either by emitting a value or sending an error or complete event. race will cancel the emissions and events of all of the other source Flows.