nativescript Global Variables Timer (JavaScript)

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

NativeScript's global timer variable lets you set timeouts and intervals for asynchronous delayed function calls.

Importing

var timer = require("timer")

Timeouts

var callback = function(){
    console.log("I will be executed once after 500ms");
}
var timeoutId = timer.setTimeout(callback, 500);

// clearing the timeout
timer.clearTimeout(timeoutId);

Intervals

var callback = function(){
    console.log("I will be executed every 500 ms")
}
var intervalId = timer.setInterval(callback, 500);

// clearing the interval
timer.clearInterval(intervalId);


Got any nativescript Question?