Skip to content

Commit 780c9be

Browse files
committed
fix(idle): using explicit injection for idle timing script
1 parent 6e0ea99 commit 780c9be

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

ng-idle-apply-timing.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@
55

66
// assumes the angular application is at least around the document's body
77

8-
/* global angular, performance */
9-
angular.element(document.body).injector().invoke(function timeApply($rootScope) {
10-
console.profile('$apply');
11-
var started = performance.now();
12-
$rootScope.$apply();
13-
var takes = performance.now() - started;
14-
console.log('idle $apply takes', takes, 'ms');
15-
console.profileEnd();
16-
return takes;
17-
});
8+
/* global performance */
9+
(function profileIdleTiming(angular) {
10+
11+
function timeApply($rootScope) {
12+
console.profile('$apply');
13+
var started = performance.now();
14+
$rootScope.$apply();
15+
var takes = performance.now() - started;
16+
console.log('idle $apply takes', takes, 'ms');
17+
console.profileEnd();
18+
return takes;
19+
}
20+
timeApply.$inject = ['$rootScope'];
21+
22+
angular.element(document.body).injector().invoke(timeApply);
23+
}(window.angular));

0 commit comments

Comments
 (0)