awaitSingleOrNull

suspend fun <T> MaybeSource<T & Any>.awaitSingleOrNull(): T?(source)

Awaits for completion of the MaybeSource without blocking the thread. Returns the resulting value, or null if no value is produced, or throws the corresponding exception if this MaybeSource produces an error.

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