-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debounce watcher causing heavy load in ngUpgrade apps #258
Comments
Personally I think this is related to: angular/angular#13540 (comment) The upgrade-adapter runs an angularjs digest cycle, when microtasks are empty. |
This describes the problem even better, but still unresolved: angular/angular#15157 |
The fix would be to give the $watch function a watchExpression as a first argument and a listener as a second. this would remove the need of the timeout as well:
|
Here's my shitty workaround: diff --git a/node_modules/ngstorage/ngStorage.js b/node_modules/ngstorage/ngStorage.js
index 0bbdb69..15d138e 100644
--- a/node_modules/ngstorage/ngStorage.js
+++ b/node_modules/ngstorage/ngStorage.js
@@ -202,8 +202,10 @@
_last$storage = angular.copy($storage);
+ var setTimeout = window[window.Zone.__symbol__('setTimeout')];
+
$rootScope.$watch(function() {
- _debounce || (_debounce = $timeout($storage.$apply, 100, false));
+ _debounce || (_debounce = setTimeout($storage.$apply, 100));
});
// #6: Use `$window.addEventListener` instead of `angular.element` to avoid the jQuery-specific `event.originalEvent`
|
The
$rootScope.$watch()
causes a high load in ngUpgraded apps (2.4.x).When I comment out the following block, the DevTools timeline shows next to no activity.
ngStorage/ngStorage.js
Lines 206 to 208 in c217d5b
The text was updated successfully, but these errors were encountered: