mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00

Instead of waiting for zone.js to patch our global declarations and break the lazy module loading optimizations there, we'll let it patch stuff before "globals" gets loaded, so that it doesn't touch (and break) the code there. Of course, that requires that functions that need legit patching need to be made aware of the zone, or get patched later on. The global.zonedCallback function makes that easy, and we use it for setTimeout/setInterval.
Globals module for defining functions part of the global context - you need only to call require for this module and all globals will be registered. For example:
require("globals");
setTimeout(function(){ console.log("Test"); }, 2000);
Global functions/objects are: setTimeout, clearTimeout, setInterval, clearInterval and console.