The goog.labs.observe.ObservableSet Class

goog.labs.observe.ObservableSet()

Creates a set of observables. An ObservableSet is a collection of observables. Observers may be reigstered and will receive notifications when any of the observables notify. This class is meant to simplify management of observations on multiple observables of the same nature.

.addObservable(observable)

Adds an observable to the set. All previously added and future observers will be added to the new observable as well. The observable will not be added if it is already registered in the set.

observable {!goog.labs.observe.Observable}
The observable to add.
returns {boolean}
Whether the observable is actually added.

.addObserver(observer)

Adds an observer that observes all observables in the set. If new observables are added to or removed from the set, the observer will be registered or unregistered accordingly. The observer will not be added if there is already an equivalent observer.

observer {!goog.labs.observe.Observer}
The observer to invoke.
returns {boolean}
Whether the observer is actually added.

.removeAll()

Removes all registered observations and observables.

.removeAllObservables()

Removes all registered observables.

.removeAllObservers()

Removes all registered observers.

.removeObservable(observable)

Removes an observable from the set. All observers registered on the set will be removed from the observable as well.

observable {!goog.labs.observe.Observable}
The observable to remove.
returns {boolean}
Whether the observable is actually removed.

.removeObserver(observer)

Removes an observer from the set. The observer will be removed from all observables in the set. Does nothing if the observer is not in the set.

observer {!goog.labs.observe.Observer}
The observer to remove.
returns {boolean}
Whether the observer is actually removed.