android-components / mozilla.components.support.base.observer / ObserverRegistry

ObserverRegistry

class ObserverRegistry<T> : Observable<T> (source)

A helper for classes that want to get observed. This class keeps track of registered observers and can automatically unregister observers if a LifecycleOwner is provided.

ObserverRegistry is thread-safe.

Constructors

Name Summary
<init> ObserverRegistry()
A helper for classes that want to get observed. This class keeps track of registered observers and can automatically unregister observers if a LifecycleOwner is provided.

Functions

Name Summary
isObserved fun isObserved(): Boolean
If the observable has registered observers.
notifyObservers fun notifyObservers(block: T.() -> Unit): Unit
Notifies all registered observers about a change.
pauseObserver fun pauseObserver(observer: T): Unit
Pauses the provided observer. No notifications will be sent to this observer until resumeObserver is called.
register fun register(observer: T): Unit
Registers an observer to get notified about changes. Does nothing if observer is already registered. This method is thread-safe.fun register(observer: T, owner: LifecycleOwner, autoPause: Boolean): Unit
fun register(observer: T, view: <ERROR CLASS>): Unit
Registers an observer to get notified about changes.
resumeObserver fun resumeObserver(observer: T): Unit
Resumes the provided observer. Notifications sent since it was last paused (see pauseObserver]) are lost and will not be re-delivered.
unregister fun unregister(observer: T): Unit
Unregisters an observer. Does nothing if observer is not registered.
unregisterObservers fun unregisterObservers(): Unit
Unregisters all observers.
wrapConsumers fun <V> wrapConsumers(block: T.(V) -> Boolean): List<(V) -> Boolean>
Returns a list of lambdas wrapping a consuming method of an observer.