firstOf

suspend fun <T> CoroutineScope.firstOf(vararg deferreds: suspend () -> T): T

Launches all provided suspending deferreds in this CoroutineScope and returns the value produced by the first block that completes.

  • Provide at least one block; otherwise the call will never complete.

  • Cancellation and error propagation semantics are delegated to the underlying dev.inmo.micro_utils.coroutines.firstOf implementation.

Return

The result produced by the first completed block.

Parameters

T

The type of the resulting value.

deferreds

The suspending blocks to race; they are started eagerly.