awaitSingle

suspend fun <T> MaybeSource<T>.awaitSingle(): T(source)

Awaits for completion of the MaybeSource without blocking the thread. Returns the resulting value, or throws if either no value is produced or 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.

Throws

if no elements were produced by this MaybeSource.


suspend fun <T> ObservableSource<T>.awaitSingle(): T(source)

Awaits the single value from the given observable without blocking the thread and returns the resulting value, or, if this observable 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 disposes of its subscription and resumes with CancellationException.

Throws

if the observable does not emit any value

if the observable emits more than one value