search

goog.disposable.IDisposable

Provided By
All Known Implementations

Interface for a disposable object. If a instance requires cleanup, it should implement this interface (it may subclass goog.Disposable).

Examples of cleanup that can be done in dispose method:

  1. Remove event listeners.
  2. Cancel timers (setTimeout, setInterval, goog.Timer).
  3. Call dispose on other disposable objects hold by current object.
  4. Close connections (e.g. WebSockets).

Note that it's not required to delete properties (e.g. DOM nodes) or set them to null as garbage collector will collect them assuming that references to current object will be lost after it is disposed.

See also http://go/mdn/JavaScript/Memory_Management.

Instance Methods