Created
March 17, 2015 12:49
-
-
Save danielearwicker/20632b7f6adbd6e2e185 to your computer and use it in GitHub Desktop.
Simple demo of pre-logging aspect
This file contains 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
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