interval-service - use $interval instead of setInterval
February 26, 2018 · View on GitHub
Instead of the default setInterval function, you should use the AngularJS wrapper service $interval
Rule based on Angular 1.x
Styleguide Reference
Examples
The following patterns are considered problems;
/*eslint angular/interval-service: 2*/
// invalid
setInterval(function() {
// ...
}, 1000) // error: You should use the $interval service instead of the default window.setInterval method
// invalid
window.setInterval(function() {
// ...
}, 1000) // error: You should use the $interval service instead of the default window.setInterval method
The following patterns are not considered problems;
/*eslint angular/interval-service: 2*/
// valid
$interval(function() {
// ...
}, 1000)
Version
This rule was introduced in eslint-plugin-angular 0.1.0