You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
At present, this would add three dirty checks to the digest cycle. Since they are all watching the same scope expression, we could instead add one dirty check that fires all three change functions as appropriate.
The impact of this change should probably be tested before committing it. It might not be worthwhile in practice.
The text was updated successfully, but these errors were encountered:
It won't actually be much help for ng-repeat, as each iteration gets its own scope. This optimization would only help when there are multiple identical watchers on the same scope. It's not that this never happens, but this is why I think the impact needs some examination.
In the newly released ng-computed module for Angular, there is a "$batchedWatch" service that can be used as a drop-in replacement for regular $scope.$watch. It will correctly deduplicate the watches as mentioned. It even caters for the case where you have different types of watches (reference/shallow and equality/deep).
It may be split out into its own module and/or project at some point in the future.
Disclaimer: the module was written by one of my coworkers.
scope.$watch('foo', function() {do.this()});
scope.$watch('foo', function() {do.that()});
scope.$watch('foo', function() {do.theOther()});
At present, this would add three dirty checks to the digest cycle. Since they are all watching the same scope expression, we could instead add one dirty check that fires all three change functions as appropriate.
The impact of this change should probably be tested before committing it. It might not be worthwhile in practice.
The text was updated successfully, but these errors were encountered: