observeShareable

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.

Return

A new instance of MutableObservable initialized with the provided value.

Parameters

initial

The initial value of the observable.

emitOnDistinct

whether to notify observers only when the value set differs from the current one.

Type Parameters

T

The type of the value being observed.