Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Observable using jquery
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;
};
@nijikokun

This comment has been minimized.

Copy link
Owner Author

@nijikokun nijikokun commented Nov 4, 2013

You would use it like so:

var method = function () {
  var self = this;

  observe(self);

  self.on('event', function () {
    ...
  });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.