Created
February 16, 2017 19:33
-
-
Save marcoslhc/684b761751828afdf6788c946bd867a0 to your computer and use it in GitHub Desktop.
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
| 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