Skip to content

Instantly share code, notes, and snippets.

@elparkino
Forked from sebastianzillessen/print-broadcasts.js
Last active August 29, 2015 14:22
Show Gist options
  • Save elparkino/f99b0b0b82915d614945 to your computer and use it in GitHub Desktop.
Save elparkino/f99b0b0b82915d614945 to your computer and use it in GitHub Desktop.
angular.module('print-broadcasts', []).config(['$provide', function ($provide) {
$provide.decorator('$rootScope', function ($delegate) {
var _emit = $delegate.$emit;
var _broadcast = $delegate.$broadcast;
$delegate.$emit = function () {
console.log("[$emit] " + arguments[0] + " (" + JSON.stringify(arguments) + ")");
return _emit.apply(this, arguments);
};
$delegate.$broadcast = function () {
console.log("[$broadcast] " + arguments[0] + " (" + JSON.stringify(arguments) + ")");
return _broadcast.apply(this, arguments);
};
return $delegate;
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment