Skip to content

Instantly share code, notes, and snippets.

@danielearwicker
Created March 17, 2015 12:49
Show Gist options
  • Save danielearwicker/20632b7f6adbd6e2e185 to your computer and use it in GitHub Desktop.
Save danielearwicker/20632b7f6adbd6e2e185 to your computer and use it in GitHub Desktop.
Simple demo of pre-logging aspect
function listenTo(target, notify) {
var proxy = {};
Object.keys(target).forEach(function(methodName) {
var targetMethod = target[methodName].bind(target);
proxy[methodName] = function() {
var args = Array.prototype.slice.call(arguments);
notify({ method: methodName, args: args });
targetMethod.apply(args);
};
});
return proxy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment