goog.disposable.IDisposable
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:
- Remove event listeners.
- Cancel timers (setTimeout, setInterval, goog.Timer).
- Call
dispose
on other disposable objects hold by current object. - 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.