Created
August 21, 2012 08:06
-
-
Save iskugor/3413357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callback = function() { | |
//do something | |
} | |
... | |
var someObject = new SomeObjectConstructor(); | |
someObject.on('click', callback); | |
... | |
function SomeObjectConstructor() {} | |
SomeObjectConstructor.prototype.on = function(type, callback, thisValue) { | |
var _this = thisValue || this; | |
var wrappedCallback = function() { | |
callback.call(_this); | |
}; | |
//assume "this._wrappedObject" exists and that it has "addEventListener" method that takes 2 arguments | |
this._wrappedObject.addEventListener(type, wrappedCallback); | |
} | |
SomeObjectConstructor.prototype.off = function(type, callback) { | |
??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment