Extensions for io.reactivex.MaybeSource

await

suspend fun <T> MaybeSource<T>.await(): T?

Awaits for completion of the maybe without blocking a thread. Returns the resulting value, null if no value was produced or throws the corresponding exception if this maybe had produced error.

awaitOrDefault

suspend fun <T> MaybeSource<T>.awaitOrDefault(default: T): T

Awaits for completion of the maybe without blocking a thread. Returns the resulting value, default if no value was produced or throws the corresponding exception if this maybe had produced error.

consumeEach

suspend fun <T> MaybeSource<T>.consumeEach(
    action: (T) -> Unit
): Unit

Subscribes to this MaybeSource and performs the specified action for each received element.

openSubscription

fun <T> MaybeSource<T>.openSubscription(): SubscriptionReceiveChannel<T>

Subscribes to this MaybeSource and returns a channel to receive elements emitted by it. The resulting channel shall be closed to unsubscribe from this source.