awaitFirst

suspend fun <T> Flow.Publisher<T>.awaitFirst(): T(source)

Awaits the first value from the given publisher without blocking the thread and returns the resulting value, or, if the publisher has produced an error, throws the corresponding exception.

This suspending function is cancellable. If the Job of the current coroutine is cancelled while the suspending function is waiting, this function immediately cancels its Flow.Subscription and resumes with CancellationException.

Throws

NoSuchElementException

if the publisher does not emit any value