Skip to content

Instantly share code, notes, and snippets.

@marcoslhc
Created February 16, 2017 19:33
Show Gist options
  • Select an option

  • Save marcoslhc/684b761751828afdf6788c946bd867a0 to your computer and use it in GitHub Desktop.

Select an option

Save marcoslhc/684b761751828afdf6788c946bd867a0 to your computer and use it in GitHub Desktop.
function countWatchers(scope) {
if (!scope) {
return 0;
}
if (scope.vm) {
let log = [scope.vm.__proto__.constructor.name, scope.$$watchers && scope.$$watchers.length]
console.log(log.join(': '));
}
let watchCount = scope.$$watchers ? scope.$$watchers.length : 0
if (scope.$$childHead) {
watchCount += countWatchers(scope.$$childHead);
}
if (scope.$$nextSibling) {
watchCount += countWatchers(scope.$$nextSibling);
}
return watchCount;
}
setInterval(() => console.log(countWatchers(angular.element("body").scope())), 3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment