mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00

Fixes name clashes and uses Node-compatible typings where possible. Changes: - setTimout et al now return NodeJS.Timer instead of number - No "console" module anymore. Everyone uses it through global.console anyway. - We have a typed "global" instance with exposed properties now. Any "freeform" accesses must go through a `(<any>global).blah` cast. - remove tns-core-modules.{base,es6,es2015}.d.ts. Those were needed as workarounds for the ES6/DOM/Node type clashes.
Timer module. Functions also can be availble in the global context if you require globals module.
require("globals");
setTimeout(function(){ log("Test"); }, 2000);
var id = setTimeout(function(){ log("Test"); }, 2000);
...
clearTimeout(id);
setInterval(function(){ log("Test"); }, 2000);
var intervalId = setInterval(function(){ log("Test"); }, 2000);
...
clearInterval(intervalId)
OR
var timer = require("timer");
timer.setTimeout(function(){ log("Test"); }, 2000);
var id = timer.setTimeout(function(){ log("Test"); }, 2000);
...
timer.clearTimeout(id);
timer.setInterval(function(){ log("Test"); }, 2000);
var intervalId = timer.setInterval(function(){ log("Test"); }, 2000);
...
timer.clearInterval(intervalId)
The second parameter for setTimeout and setInterval is optional with default value of 0.