race With
suspend fun <T> ERROR CLASS: Symbol not found for Flow<T>.raceWith(other: ERROR CLASS: Symbol not found for Flow<T>): T(source)
Returns the value from flow that emits first.
Both flows are collected concurrently.
Only the first value is emitted.
If both flows have failed, returns the last exception.
Example:
val fast = flow {
delay(100)
emit("Fast")
}
val slow = flow {
delay(1000)
emit("Slow")
}
val result = raceWith(fast, slow)
println(result)Content copied to clipboard
In this example, the function returns "Fast", because the first flow emits earlier than the second one.