In my app I have to do some operations with some frequency without user intervention. To do that I need a timer which launches a task again and again.
For example, I have to show warnings about the state related to business rules. This warning come from calculations made daily over the data stored in the app.
What is the better approach to set a temporized task like in a timer clock?
setInterval() alone may cause you trouble if any changes you make inside it have to be propagated to any of your views, because of the way zone.js and angular2 work together - e.g. this article -
and RxJS schedulePeriodic() is mostly just setInterval() with some bells and whistles added, so it still does not solve your problem. You must take zone into account.
I wrote an injectable provider class that’s pretty short and self contained to do exactly what you’re asking for. Been using it for a couple of months with no problems. It is here.