mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
dialogs and timer lazy require
This commit is contained in:
@ -16,29 +16,50 @@ if (platform.device.os === platform.platformNames.android) {
|
|||||||
global.console.dump = function (args) { c.dump(args); };
|
global.console.dump = function (args) { c.dump(args); };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tm;
|
||||||
|
function getTimer() {
|
||||||
|
if (!tm) {
|
||||||
|
tm = require("timer");
|
||||||
|
}
|
||||||
|
|
||||||
|
return tm;
|
||||||
|
}
|
||||||
|
|
||||||
global.setTimeout = function (callback, milliseconds) {
|
global.setTimeout = function (callback, milliseconds) {
|
||||||
let tm = require("timer");
|
return getTimer().setTimeout(callback, milliseconds);
|
||||||
return tm.setTimeout(callback, milliseconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global.clearTimeout = function (id) {
|
global.clearTimeout = function (id) {
|
||||||
let tm = require("timer");
|
getTimer().clearTimeout(id);
|
||||||
tm.clearTimeout(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global.setInterval = function (callback, milliseconds) {
|
global.setInterval = function (callback, milliseconds) {
|
||||||
let tm = require("timer");
|
return getTimer().setInterval(callback, milliseconds);
|
||||||
return tm.setInterval(callback, milliseconds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global.clearInterval = function (id) {
|
global.clearInterval = function (id) {
|
||||||
let tm = require("timer");
|
getTimer().clearInterval(id);
|
||||||
tm.clearInterval(id);
|
}
|
||||||
|
|
||||||
|
var dm;
|
||||||
|
function getDialogs() {
|
||||||
|
if (!dm) {
|
||||||
|
dm = require("ui/dialogs");
|
||||||
|
}
|
||||||
|
|
||||||
|
return dm;
|
||||||
}
|
}
|
||||||
|
|
||||||
global.alert = function (args) {
|
global.alert = function (args) {
|
||||||
let dm = require("ui/dialogs");
|
return getDialogs().alert(args);
|
||||||
return dm.alert(args);
|
}
|
||||||
|
|
||||||
|
global.confirm = function (args) {
|
||||||
|
return getDialogs().confirm(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
global.prompt = function (args) {
|
||||||
|
return getDialogs().prompt(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
var xhr = require("../xhr/xhr");
|
var xhr = require("../xhr/xhr");
|
||||||
|
Reference in New Issue
Block a user