I'm working on a personal project that uses the setInterval functions. I noticed Nativescript has the 'timer' module with setInterval and implemented that into my project.
Is it worth importing the Nativescript timer module every time I want to use setInterval() in my app or can I just use the Javascript setinterval() instead?
Example of code ( angular 2 with typescript ):
import { setInterval, clearInterval } from 'timer'
/* skip some code */
private setInterval = setInterval;
private clearInterval = clearInterval;
/* skip some code */
time() {
this.interval = this.setInterval(() => {
this.duration = this.clock.formatTime(time)
}, 1)
}
source : http://docs.nativescript.org/angular/cookbook/timer
On a side note, is the above way the correct way to implement the timer module? My only experience so far is the Angular 2 - Nativescript tutorial with the color module but the timer module is slightly different.