Created
April 14, 2015 14:56
-
-
Save sebastianzillessen/3d2cea1aa5d6433aa2ac to your computer and use it in GitHub Desktop.
AngularJS decorator to display all $emit and $broadcast events of an application.
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
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