mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Zone-aware versions of certain APIs: setTimeout/setInterval mostly.
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.
This commit is contained in:
@@ -29,6 +29,14 @@ global.loadModule = function(name: string): any {
|
||||
}
|
||||
}
|
||||
|
||||
global.zonedCallback = function(callback: Function): Function {
|
||||
if (global.zone) {
|
||||
return global.zone.bind(callback);
|
||||
} else {
|
||||
return callback;
|
||||
}
|
||||
}
|
||||
|
||||
global.registerModule("timer", () => require("timer"));
|
||||
global.registerModule("ui/dialogs", () => require("ui/dialogs"));
|
||||
global.registerModule("xhr", () => require("xhr"));
|
||||
|
||||
Reference in New Issue
Block a user