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 and emits its result. Every time the returned completable is subscribed, it starts a new coroutine. Unsubscribing cancels running coroutine. Coroutine context can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. Method throws IllegalArgumentException if provided context contains a Job instance.

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.

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 and emits its result. If block result is null, onComplete is invoked without a value. Every time the returned observable is subscribed, it starts a new coroutine. Unsubscribing cancels running coroutine. Coroutine context can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. Method throws IllegalArgumentException if provided context contains a Job instance.

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.

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 and emits its result. Every time the returned observable is subscribed, it starts a new coroutine. Unsubscribing cancels running coroutine. Coroutine context can be specified with context argument. If the context does not have any dispatcher nor any other ContinuationInterceptor, then Dispatchers.Default is used. Method throws IllegalArgumentException if provided context contains a Job instance.