Package kotlinx.coroutines.rx2

Utilities for RxJava 2.x.

Types

SchedulerCoroutineDispatcher

class SchedulerCoroutineDispatcher : 
    CoroutineDispatcher,
    Delay

Implements CoroutineDispatcher on top of an arbitrary Scheduler.

Extensions for External Classes

io.reactivex.CompletableSource

io.reactivex.MaybeSource

io.reactivex.ObservableSource

io.reactivex.Scheduler

io.reactivex.SingleSource

kotlinx.coroutines.CoroutineScope

kotlinx.coroutines.Deferred

kotlinx.coroutines.Job

kotlinx.coroutines.channels.ReceiveChannel

kotlinx.coroutines.flow.Flow

Functions

rxCompletable

fun rxCompletable(
    context: CoroutineContext = EmptyCoroutineContext,
    block: suspend CoroutineScope.() -> Unit
): Completable

Creates cold Completable that runs a given block in a coroutine. Every time the returned completable is subscribed, it starts a new coroutine. Unsubscribing cancels running coroutine.

rxFlowable

fun <T : Any> rxFlowable(
    context: CoroutineContext = EmptyCoroutineContext,
    block: suspend ProducerScope<T>.() -> Unit
): Flowable<T>

Creates cold flowable that will run a given block in a coroutine. Every time the returned flowable is subscribed, it starts a new coroutine. Coroutine emits items with send. Unsubscribing cancels running coroutine.

rxMaybe

fun <T> rxMaybe(
    context: CoroutineContext = EmptyCoroutineContext,
    block: suspend CoroutineScope.() -> T?
): Maybe<T>

Creates cold maybe that will run a given block in a coroutine. Every time the returned observable is subscribed, it starts a new coroutine. Coroutine returns a single, possibly null value. Unsubscribing cancels running coroutine.

rxObservable

fun <T : Any> rxObservable(
    context: CoroutineContext = EmptyCoroutineContext,
    block: suspend ProducerScope<T>.() -> Unit
): Observable<T>

Creates cold observable that will run a given block in a coroutine. Every time the returned observable is subscribed, it starts a new coroutine. Coroutine emits items with send. Unsubscribing cancels running coroutine.

rxSingle

fun <T : Any> rxSingle(
    context: CoroutineContext = EmptyCoroutineContext,
    block: suspend CoroutineScope.() -> T
): Single<T>

Creates cold single that will run a given block in a coroutine. Every time the returned observable is subscribed, it starts a new coroutine. Coroutine returns a single value. Unsubscribing cancels running coroutine.