Observables

Set of useful extensions on Observable and collections of observables.

Functions

Link copied to clipboard
fun <T, O> List<Observable<T>>.combineLatest(collector: (List<T>) -> O): Observable<Option<O>>

Collects the latest values emitted by a list of Observables and transforms them into a new Observable using the provided collector function.

Link copied to clipboard
fun <T, C : Collection<T>, R, O> Observable<C>.combineLatestCollection(transformer: (T) -> Observable<R>, aggregator: (List<R>) -> O): Observable<O>

Maps every element of the current collection to an observable through transformer, and aggregates their current values through aggregator. The result is recomputed whenever the collection changes or any mapped observable emits; observables of elements leaving the collection are unsubscribed.

Link copied to clipboard
fun <T> Observable<Option<T>>.currentOrNull(): T?

Retrieves the current value of the observable if present, or null if no value is available.

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

Maps the current value of this Observable to an inner observable through transform, and mirrors the inner observable of the most recent value only: whenever this observable emits, the previous inner observable is unsubscribed and the new one is followed.