The goog.labs.observe.SimpleObservable Class

goog.labs.observe.SimpleObservable
> goog.Disposable

goog.labs.observe.SimpleObservable(opt_actualObservable)

A simple implementation of {@code goog.labs.observe.Observable} that can be used as a standalone observable or as a base class for other observable object. When another class wants to implement observable without extending {@code SimpleObservable}, they can create an instance of {@code SimpleObservable}, specifying {@code opt_actualObservable}, and delegate to the instance. Here is a trivial example:

   ClassA = function() {
     goog.base(this);
     this.observable_ = new SimpleObservable(this);
     this.registerDisposable(this.observable_);
   };
   goog.inherits(ClassA, goog.Disposable);

   ClassA.prototype.observe = function(observer) {
     this.observable_.observe(observer);
   };

   ClassA.prototype.unobserve = function(observer) {
     this.observable_.unobserve(observer);
   };

   ClassA.prototype.notify = function(opt_data) {
     this.observable_.notify(opt_data);
   };
 
opt_actualObservable {!goog.labs.observe.Observable=}
Optional observable object. Defaults to 'this'. When used as base class, the parameter need not be given. It is only useful when using this class to implement implement {@code Observable} interface on another object, see example above.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.notify()

.observe()

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.unobserve()