Skip to content

Instantly share code, notes, and snippets.

/.java Secret

Created August 3, 2015 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d44c1aa9fa7df0e02034 to your computer and use it in GitHub Desktop.
Save anonymous/d44c1aa9fa7df0e02034 to your computer and use it in GitHub Desktop.
function countWatches(rootScope) {
var watchers = 0;
function visit(scope) {
if (scope.$$watchers) {
watchers += scope.$$watchers.length;
}
if (scope.$$childHead) {
visit(scope.$$childHead);
}
if (scope.$$nextSibling) {
visit(scope.$$nextSibling);
}
}
visit(rootScope);
return watchers;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment