Created
November 4, 2013 06:22
-
-
Save nijikokun/7298768 to your computer and use it in GitHub Desktop.
Observable using jquery
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 observe = function (obj) { | |
var pojo = jQuery({}); | |
jQuery.each({ 'on': 0, 'one': 0, 'off': 0, 'trigger': 'emit' }, function (method, alias) { | |
obj[alias ? alias : method] = function () { | |
pojo[method].apply(obj, arguments); | |
return obj; | |
} | |
}); | |
return obj; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You would use it like so: