Extensions for rx.Observable

awaitFirst

suspend fun <T> Observable<T>.awaitFirst(): T

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

awaitFirstOrDefault

suspend fun <T> Observable<T>.awaitFirstOrDefault(
    default: T
): T

Awaits for the first value from the given observable or the default value if none is emitted without blocking a thread and returns the resulting value or throws the corresponding exception if this observable had produced error.

awaitFirstOrElse

suspend fun <T> Observable<T>.awaitFirstOrElse(
    defaultValue: () -> T
): T

Awaits for the first value from the given observable or call defaultValue to get a value if none is emitted without blocking a thread and returns the resulting value or throws the corresponding exception if this observable had produced error.

awaitFirstOrNull

suspend fun <T> Observable<T>.awaitFirstOrNull(): T?

Awaits for the first value from the given observable or null value if none is emitted without blocking a thread and returns the resulting value or throws the corresponding exception if this observable had produced error.

awaitLast

suspend fun <T> Observable<T>.awaitLast(): T

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

awaitSingle

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

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

consumeEach

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

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

iterator

operator fun <T> Observable<T>.iterator(): ChannelIterator<T>

Subscribes to this Observable and returns an iterator to receive elements emitted by it.

openSubscription

fun <T> Observable<T>.openSubscription(
    request: Int = 0
): SubscriptionReceiveChannel<T>

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