From the angular's documentation of $interval service:
invokeApply (optional) boolean: If set to false skips model dirty checking, otherwise will invoke fn within the $apply block.
Which can lead us to a conclusion that $rootScope.$apply wouldn't be called if I set invokeApply
as false.
However, from the source of $interval I learned that deferred.notify
is called each tick, which makes sense. What does not, is the fact that during deferred.notify
execution $rootScope.$evalAsync
is called, which in order calls $rootScope.$digest
. So all the dirty checking still happens. Am I missing something here?
The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds). The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed. The ID value returned by setInterval() is used as the parameter for the clearInterval() method.
The return value of registering an interval function is a promise. This promise will be notified upon each tick of the interval, and will be resolved after count iterations, or run indefinitely if count is not defined. The value of the notification will be the number of iterations that have run.
To cancel an interval, call $interval.cancel(promise). In tests you can use $interval.flush(millis) to move forward by millis milliseconds and trigger any functions scheduled to run in that time. Note : Intervals created by this service must be explicitly destroyed when you are finished with them.
Definition and Usage. The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).
Bug already filed!
https://github.com/angular/angular.js/pull/5903
You are missing nothing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With