MutableObservables

Factory and utilities for mutable observables.

Functions

Link copied to clipboard
fun <T> observe(initial: T, emitOnDistinct: Boolean = true): MutableObservable<T>

Creates and returns a new instance of a MutableObservable initialized with the given value. The resulting observable allows its state to be modified and notifies registered observers of any changes.

Link copied to clipboard
fun <T> observeShareable(initial: T, emitOnDistinct: Boolean = true): MutableObservable<T>

Creates a MutableObservable initialized with initial, like observe, whose current value can be read from any thread, always returning the latest value set. Only reading the current value is shared: setting it, registering observers, and deriving further observables must still happen on a single thread.