Skip to content

Instantly share code, notes, and snippets.

@jaz303
Last active December 20, 2015 02:19
Show Gist options
  • Save jaz303/6055081 to your computer and use it in GitHub Desktop.
Save jaz303/6055081 to your computer and use it in GitHub Desktop.
function Foo() {
this.destructors = [];
}
Foo.prototype.bind = function(ele, type, handler) {
ele.addEventListener(type, handler);
this.destructors.push(function() {
ele.removeEventListener(type, handler);
});
}
Foo.prototype.teardown = function() {
this.destructors.forEach(function(fn) { fn(); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment