Created
March 24, 2022 18:14
-
-
Save hoc081098/3e0d6bbf7eaddd26348108e9edf226f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalCoroutinesApi | |
public fun <T> race(flow1: Flow<T>, flow2: Flow<T>, vararg flows: Flow<T>): Flow<T> = | |
race( | |
buildList(capacity = 2 + flows.size) { | |
add(flow1) | |
add(flow2) | |
addAll(flows) | |
} | |
) | |
@ExperimentalCoroutinesApi | |
public fun <T> Flow<T>.raceWith(flow: Flow<T>, vararg flows: Flow<T>): Flow<T> = race( | |
buildList(capacity = 2 + flows.size) { | |
add(this@raceWith) | |
add(flow) | |
addAll(flows) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment