first

suspend fun <T> List<Deferred<T>>.first(scope: CoroutineScope, cancelOnResult: Boolean = true): T(source)

Returns the value of the first Deferred from this list to complete, using the given scope. Other deferred values are cancelled if cancelOnResult is true.

Return

The value of the first completed deferred

Parameters

scope

The CoroutineScope in which to await the deferred values

cancelOnResult

If true, cancels all other deferred values after the first completes. Defaults to true

Type Parameters

T

The type of the deferred values