invoke On First Of
suspend fun <T, O> CoroutineScope.invokeOnFirstOf(cancelOnResult: Boolean = true, block: DoWithFirstBuilder<T>.() -> Unit, callback: suspend (T) -> O): O(source)
Builds multiple deferred computations using DoWithFirstBuilder and invokes callback on the first one to complete. Other deferred computations are cancelled if cancelOnResult is true.
Return
The result of applying the callback to the first completed value
Parameters
cancel On Result
If true, cancels all other computations after the first completes. Defaults to true
block
Builder DSL to define the deferred computations
callback
The suspending function to apply to the first completed value
Type Parameters
T
The type of the deferred values
O
The type of the result after applying the callback