Created
April 22, 2016 21:45
-
-
Save supertinou/c468723498615f2a9cea47399389c4b5 to your computer and use it in GitHub Desktop.
AngularJS : Capture and console log all broadcasts
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
.config(function($provide) { | |
$provide.decorator("$rootScope", function($delegate) { | |
var Scope = $delegate.constructor; | |
var origBroadcast = Scope.prototype.$broadcast; | |
var origEmit = Scope.prototype.$emit; | |
Scope.prototype.$broadcast = function($scope) { | |
console.log("$broadcast was called on $scope " + $scope.$id + " with arguments:", | |
arguments); | |
return origBroadcast.apply(this, arguments); | |
}; | |
Scope.prototype.$emit = function($scope) { | |
console.log("$emit was called on $scope " + $scope.$id + " with arguments:", | |
arguments); | |
return origEmit.apply(this, arguments); | |
}; | |
return $delegate; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment