observe

fun observe(observer: Consumer<M>): Disposable

Add an observer of model changes to this loop. If mostRecentModel is non-null, the observer will immediately be notified of the most recent model. The observer will be notified of future changes to the model until the loop or the returned Disposable is disposed.

The observer is guaranteed to get notified of models in the same order that they are emitted by the loop, but there is no guarantee about which model will be the first one observed.

Return

a Disposable that can be used to stop further notifications to the observer

Parameters

observer

a non-null observer of model changes

Throws

if the loop has been disposed