awaitFirstOrDefault

suspend fun <T> Publisher<T>.awaitFirstOrDefault(default: T): T(source)

Awaits the first value from the given publisher, or returns the default value if none is emitted, without blocking the thread, and returns the resulting value, or, if this 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 Subscription and resumes with CancellationException.