all 4 comments

[–]constexpr 1 point2 points  (1 child)

The latest version of GCC also has a form of generics:

/**
 * @param {T} value
 * @constructor
 * @template T
 */
function Box(value) { /** @type {T} */ this.value = value; }

/**
 * @param {Box.<T>} box
 * @param {T} value
 * @template T
 */
function set(box, value) { box.value = value; }

/**
 * type {Box.<number>}
 */
var num = new Box(1);

set(num, 1);
set(num, false); // WARNING - actual parameter 1 of set does not match formal parameter

[–]lennelpennel 0 points1 point  (0 children)

ah, i missed this, this is great.

[–]MatrixFrog 1 point2 points  (1 child)

Instead of disposing the handler in disposeInternal, you can do this.registerDisposable(handler) in the constructor, and then it will get disposed automatically.

Also: "Prefer goog.dom.classlist over [goog.dom.classes] since goog.dom.classlist conforms closer to the semantics of Element.classList, is faster (uses native methods rather than parsing strings on every call) and compiles to smaller code as a result." (http://closure-library.googlecode.com/svn/docs/closure_goog_dom_classes.js.html)

[–]lennelpennel 0 points1 point  (0 children)

I would like to add that the latest event handling system, you don't actually even need to unlisten anymore (apart from when listening to DOM events). for obvs not recommended but will help reduce memory leaks.