本文整理汇总了TypeScript中tns-core-modules/timer.setTimeout函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setTimeout函数的具体用法?TypeScript setTimeout怎么用?TypeScript setTimeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setTimeout函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: onPullToRefreshInitiated
public onPullToRefreshInitiated(args: ListViewEventData) {
console.log("Pull To Refresh Initiated");
const listView = args.object;
const that = new WeakRef(this);
if (this._allItems.length !== 0) {
// Add 1 more item to the '_sourceDataItems',
// Simulating a scenario where the 'backend' has been updated with 1 more item that could be loaded by 'load on demand'
this.addItemsToSourceDataItems(1);
setTimeout(function () {
let thisInstance = that.get();
let numberOfItemsToAdd = 1;
for (let i = 0; i < numberOfItemsToAdd; i++) {
if (thisInstance._allItems.length !== 0) {
thisInstance._dataItems.splice(0, 0, thisInstance.getNextItemFromServer());
}
}
listView.notifyPullToRefreshFinished(thisInstance.isLoadOnDemandModeNeeded());
}, 1000);
} else {
args.returnValue = false;
listView.notifyPullToRefreshFinished(this.isLoadOnDemandModeNeeded());
}
}
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:25,代码来源:listview-fixed-size-auto-with-small-source.component.ts
示例2: test_setTimeout_shouldReturnNumber
export function test_setTimeout_shouldReturnNumber() {
let id = timer.setTimeout(() => {
//
});
timer.clearTimeout(id);
TKUnit.assertTrue(typeof id === "number", "Callback should return number!");
};
示例3: onLoadMoreDataRequested
public onLoadMoreDataRequested(args: LoadOnDemandListViewEventData) {
const that = new WeakRef(this);
const listView: RadListView = args.object;
if (!this._itemsLoading) {
if (this._sourceDataItems.length !== 0) {
console.log("Load More Data Requested WILL LOAD");
// Set flag to make sure that items are being loaded in the correct order.
// This is necessary due to the asyc nature of getting and adding new items
// to the 'items' property of the RadListView that may be caused by remote server API lag.
this._itemsLoading = true;
setTimeout(function () {
let thatInstance = that.get();
thatInstance.addMoreItemsFromSource(1);
// Reset the flag to allow next calls of 'loadMoreDataRequested' to load more items
thatInstance._itemsLoading = false;
listView.notifyLoadOnDemandFinished();
}, 1500);
} else {
console.log("Load More Data Requested CANNOT LOAD");
args.returnValue = false;
listView.notifyLoadOnDemandFinished(true);
}
}
}
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:29,代码来源:listview-fixed-size-auto-with-small-source.component.ts
示例4: test_setTimeout_callbackNotCalled
export function test_setTimeout_callbackNotCalled() {
let completed = false;
const id = timer.setTimeout(() => completed = true, 10);
timer.clearTimeout(id);
TKUnit.wait(30 / 1000);
TKUnit.assert(!completed, "Callback should not be called after the specified time!");
};
示例5: test_clearTimeout_insideCallback
export function test_clearTimeout_insideCallback() {
let completed = false;
let id = timer.setTimeout(() => {
completed = true;
timer.clearTimeout(id);
});
TKUnit.waitUntilReady(() => completed, 0.5);
TKUnit.assert(completed, "Callback should be called");
}
示例6: test_clearTimeout_immediatelyAfterCreate
export function test_clearTimeout_immediatelyAfterCreate() {
let completed = false;
const id = timer.setTimeout(() => {
completed = true;
});
timer.clearTimeout(id);
TKUnit.wait(0.02);
TKUnit.assert(!completed, "Callback should not be called");
}
示例7: createPage
export function createPage() {
function createTxt(text: string) {
var tv = new textView.TextView();
tv.text = text;
return tv;
}
var page = new pages.Page();
var scrollView = new scroll.ScrollView();
function performGet() {
console.log("Getting CSS");
http.getString("http://192.168.54.36:8080/test.css").then(
function (r) {
console.log("Applying CSS");
page.css = r;
timer.setTimeout(performGet, 1000);
},
function (e) {
console.log("Error: " + e);
timer.setTimeout(performGet, 1000);
});
}
var stack = new stacks.StackLayout();
scrollView.content = stack;
var counter = 0;
var btn = new btns.Button();
btn.text = "tap";
btn.on(btns.Button.tapEvent, function () {
btn.text = "hi: " + counter++;
});
btn.isEnabled = false;
stack.addChild(btn);
stack.addChild(createTxt("this is label"));
var info = new btns.Button();
info.text = "info";
info.className = "info";
info.on(btns.Button.tapEvent, function () {
info.text = "hi: " + counter++;
btn.isEnabled = true;
});
stack.addChild(info);
stack.addChild(createTxt("this is another label"));
page.content = scrollView;
timer.setTimeout(performGet, 2000);
return page;
}
示例8: onLoadMoreItemsRequested
public onLoadMoreItemsRequested(args: LoadOnDemandListViewEventData) {
const that = new WeakRef(this);
const listView: RadListView = args.object;
if (this._sourceDataItems.length > 0) {
setTimeout(function () {
that.get().addMoreItemsFromSource(2);
listView.notifyLoadOnDemandFinished();
}, 1500);
} else {
args.returnValue = false;
listView.notifyLoadOnDemandFinished(true);
}
}
开发者ID:telerik,项目名称:nativescript-ui-samples-angular,代码行数:13,代码来源:listview-dynamic-size-auto.component.ts
示例9: test_clearTimeout_multipleTimes_afterTick
export function test_clearTimeout_multipleTimes_afterTick() {
let completed = false;
const id = timer.setTimeout(() => {
completed = true;
});
TKUnit.waitUntilReady(() => completed, 0.5);
TKUnit.assert(completed, "Callback should be called");
timer.clearTimeout(id);
timer.clearTimeout(id);
}
示例10: test_setTimeout_callbackCalledAfterSpecifiedTime
export function test_setTimeout_callbackCalledAfterSpecifiedTime() {
let completed = false;
// >> timer-set-ten
const id = timer.setTimeout(() => {
// >> (hide)
completed = true;
// << (hide)
}, 10);
// << timer-set-ten
TKUnit.waitUntilReady(() => completed, 1);
timer.clearTimeout(id);
TKUnit.assert(completed, "Callback should be called after the specified time!");
};