Path: blob/trunk/third_party/closure/goog/disposable/idisposable.js
4167 views
/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56/**7* @fileoverview Definition of the disposable interface. A disposable object8* has a dispose method to to clean up references and resources.9*/101112goog.provide('goog.disposable.IDisposable');1314goog.require('goog.utils');15161718/**19* Interface for a disposable object. If a instance requires cleanup, it should20* implement this interface (it may subclass goog.Disposable).21*22* Examples of cleanup that can be done in `dispose` method:23* 1. Remove event listeners.24* 2. Cancel timers (setTimeout, setInterval, goog.Timer).25* 3. Call `dispose` on other disposable objects hold by current object.26* 4. Close connections (e.g. WebSockets).27*28* Note that it's not required to delete properties (e.g. DOM nodes) or set them29* to null as garbage collector will collect them assuming that references to30* current object will be lost after it is disposed.31*32* See also http://go/mdn/JavaScript/Memory_Management.33*34* @record35*/36goog.disposable.IDisposable = function() {};373839/**40* Disposes of the object and its resources.41* @return {void} Nothing.42*/43goog.disposable.IDisposable.prototype.dispose = goog.utils.abstractMethod;444546/**47* @return {boolean} Whether the object has been disposed of.48*/49goog.disposable.IDisposable.prototype.isDisposed = goog.utils.abstractMethod;505152