Package kotlinx.coroutines.experimental.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.experimental.Deferred

kotlinx.coroutines.experimental.Job

kotlinx.coroutines.experimental.channels.ReceiveChannel

Functions

rxCompletable

fun rxCompletable(
    context: CoroutineContext = DefaultDispatcher,
    parent: Job? = null,
    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> rxFlowable(
    context: CoroutineContext = DefaultDispatcher,
    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 = DefaultDispatcher,
    parent: Job? = null,
    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> rxObservable(
    context: CoroutineContext = DefaultDispatcher,
    parent: Job? = null,
    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> rxSingle(
    context: CoroutineContext = DefaultDispatcher,
    parent: Job? = null,
    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.