AbstractObservable

abstract class AbstractObservable<T>(emitOnDistinct: Boolean = true) : Observable<T> (source)

The base implementation of Observable: it keeps the registered callbacks, hands out their handles, and notifies them of the values published through updateAndNotify.

Observables holding their own state publish it whenever it changes. Observables derived from other sources compute their value through computeFresh, and observe their sources, through observeSource, only while they are observed.

Parameters

emitOnDistinct

whether to emit only when the new derived value is different from the current one. If so, the first registration computes the current value even when not delivering it, so that the first emission can be compared against it; otherwise, a registration that does not deliver the current value computes nothing.

Type Parameters

T

The type of data being observed.

Inheritors

Constructors

Link copied to clipboard
constructor(emitOnDistinct: Boolean = true)

Properties

Link copied to clipboard
open override val current: T

The current value: while observed, the latest value published; otherwise, a freshly computed one. Observables holding their own state may read it directly.

Link copied to clipboard
Link copied to clipboard
override val observerCount: Int

Functions

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
open override fun dispose()
Link copied to clipboard
open override fun <S> map(transform: (T) -> S): Observable<S>
Link copied to clipboard
open override fun <O, R> mergeWith(other: Observable<O>, merge: (T, O) -> R): Observable<R>
Link copied to clipboard
open override fun onChange(notifyOnRegistration: Boolean, callback: (T) -> Unit): Disposable
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.