When invoking $scope.$apply()
ten times consecutively, it is expected that ten root scope digests will occur.
If the call to $scope.$apply()
is debounced so that the trailing call always completes, can we assume that the final state of the application remains unchanged compared to when there was no debounce in effect?
Is there any way to predict the duration of successive root scope digests, especially considering a previous digest has just finished?
Edit:
To clarify my question's purpose, let's consider a scenario. There is a controller called MyController
, which has an instance for each directive called MyDirective
.
These controllers listen for an event called my-event
and trigger a root-scope digest every time this event occurs.
Ten instances of MyDirective
are displayed on the UI using ng-repeat
.
Another component triggers an event called my-event
. Subsequently, all ten instances of MyController
initiate a root-scope digest.
If we overlook the sanity of this situation, the question at hand is: If I debounce the root-scope digest attempts made by MyController
, ensuring that the trailing attempt always executes, does the program's correctness remain intact?
var service = require('my-service');
function MyController($scope) {
this._$scope = $scope;
myService.on('my-event', this.triggerRootScopeDigest.bind(this));
}
MyController.prototype.triggerRootScopeDigest = function() {
this._$scope.apply();
}