Home

# Class goog.Disposable

Class that provides the basic implementation for disposable objects. If your class holds one or more references to COM objects, DOM nodes, or other disposable objects, it should extend this class or implement the disposable interface (defined in goog.disposable.IDisposable).

Instance Method Summary
| `dispose()` 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.

`disposeInternal()`

Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' {@code disposeInternal} method. Everywhere else the public {@code dispose} method must be used. For example:

    mypackage.MyClass = function() {
    goog.base(this);
    // Constructor logic specific to MyClass.
    ...
    };
    goog.inherits(mypackage.MyClass, goog.Disposable);

    mypackage.MyClass.prototype.disposeInternal = function() {
    goog.base(this, 'disposeInternal');
    // Dispose logic specific to MyClass.
    ...
    };

| `isDisposed() ⇒ boolean`
| `registerDisposable(?goog.disposable.IDisposable disposable)` Associates a disposable object with this object so that they will be disposed together.

Static Method Summary
| `clearUndisposedObjects()` Clears the registry of undisposed objects but doesn't dispose of them.
| `getUndisposedObjects() ⇒ !Array`