new 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).
Methods
-
addOnDisposeCallback(callback [, opt_scope])
-
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Parameters:
Name Type Argument Description callback
function The callback function. opt_scope
T <optional>
An optional scope to call the callback in. -
dispose()
-
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend `goog.Disposable` should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns:
Nothing.- Type
- void
-
<protected> disposeInternal()
-
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend `goog.Disposable` should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' `disposeInternal` method. Everywhere else the public `dispose` method must be used. For example:
mypackage.MyClass = function() { mypackage.MyClass.base(this, 'constructor'); // Constructor logic specific to MyClass. ... }; goog.inherits(mypackage.MyClass, goog.Disposable); mypackage.MyClass.prototype.disposeInternal = function() { // Dispose logic specific to MyClass. ... // Call superclass's disposeInternal at the end of the subclass's, like // in C++, to avoid hard-to-catch issues. mypackage.MyClass.base(this, 'disposeInternal'); };
-
isDisposed()
-
Returns:
Whether the object has been disposed of.- Type
- boolean
-
registerDisposable(disposable)
-
Associates a disposable object with this object so that they will be disposed together.
Parameters:
Name Type Description disposable
goog.disposable.IDisposable that will be disposed when this object is disposed.