awaitSingle

suspend fun <T> Publisher<T>.awaitSingle(): T

Awaits for the single value from the given publisher without blocking a thread and returns the resulting value or throws the corresponding exception if this publisher had produced error.

This suspending function is cancellable. If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function immediately resumes with CancellationException.

Exceptions

NoSuchElementException - if publisher does not emit any value

IllegalArgumentException - if publisher emits more than one value