The goog.labs.observe.ObservationSet Class

goog.labs.observe.ObservationSet(opt_defaultScope)

A set of observations. An observation is defined by an observable and an observer. The set keeps track of observations and allows their removal.

opt_defaultScope {!Object=}
Optional function scope to use when using {@code observeWithFunction} and {@code unobserveWithFunction}.

.observe(observable, observer)

Observes the given observer on the observable.

observable {!goog.labs.observe.Observable}
The observable to observe on.
observer {!goog.labs.observe.Observer}
The observer.
returns {boolean}
True if the observer is successfully registered.

.observeWithFunction(observable, fn, opt_scope)

Observes the given function on the observable.

observable {!goog.labs.observe.Observable}
The observable to observe on.
fn {function(!goog.labs.observe.Notice)}
The handler function.
opt_scope {!Object=}
Optional scope.
returns {goog.labs.observe.Observer}
The registered observer object. If the observer is not successfully registered, this will be null.

.removeAll()

Removes all observations registered through this set.

.unobserve(observable, observer)

Unobserves the given observer from the observable.

observable {!goog.labs.observe.Observable}
The observable to unobserve from.
observer {!goog.labs.observe.Observer}
The observer.
returns {boolean}
True if the observer is successfully removed.

.unobserveWithFunction(observable, fn, opt_scope)

Unobserves the given function from the observable.

observable {!goog.labs.observe.Observable}
The observable to unobserve from.
fn {function(!goog.labs.observe.Notice)}
The handler function.
opt_scope {!Object=}
Optional scope.
returns {boolean}
True if the observer is successfully removed.