RxUtils

object RxUtils

Functions

Link copied to clipboard
fun <T> Observable<T>.await(): Pair<T?, Throwable?>

Blocks the current thread and waits for the Observable to complete, then returns a Pair containing the result, and the error (if any) This must not be called from the Main thread (and will throw an IllegalStateException if done so) as that would freeze the UI

Link copied to clipboard
fun <T, R> combineLatest(sources: List<Observable<T>>, combineFunction: FuncN<R>): Observable<R>

Combines a list of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function.

Link copied to clipboard
fun <T> createActionSubscriber(onNext: Action1<in T>, onError: Action1<Throwable> = Action1 {}, onCompleted: Action0 = Action0 {}): Subscriber<T>

Creates a subscriber that forwards the onXXX method calls to callbacks.

Link copied to clipboard
fun <T, R> Observable<T>.map(func: (T) -> R): Observable<R>

Returns an Observable that applies a specified function to each item emitted by the source Observable and emits the results of these function applications.

Link copied to clipboard
fun <T> Observable<T>.onBackpressureBuffer(): Observable<T>

Instructs an Observable that is emitting items faster than its observer can consume them to buffer these items indefinitely until they can be emitted.

Link copied to clipboard
fun schedule(delay: Long, unit: TimeUnit?, callback: Long.() -> Unit): Subscription

Runs the callback after the specified delay

Link copied to clipboard
fun <T> Observable<T>.subscribe(onNext: T.() -> Unit): Subscription

Subscribe to the Observable. This is equivalent to subscribe(createActionSubscriber(onNext))

fun <T> Observable<T>.subscribe(subscriber: Subscriber<in T>): Subscription

Subscribe to the Observable

Link copied to clipboard
fun <T, R> Observable<T>.switchMap(func: (T) -> Observable<R>): Observable<R>

Returns a new Observable by applying a function that you supply to each item emitted by the source Observable that returns an Observable, and then emitting the items emitted by the most recently emitted of these Observables.

Link copied to clipboard
fun timer(delay: Long, unit: TimeUnit?): Observable<Long>

Returns an Observable that emits 0L after a specified delay, and then completes.

Properties

Link copied to clipboard
val empty: Observable<Any>