• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript timer.setTimeout函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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!");
};
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:7,代码来源:timer-tests.ts


示例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!");
};
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:9,代码来源:timer-tests.ts


示例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");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:11,代码来源:timer-tests.ts


示例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");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:11,代码来源:timer-tests.ts


示例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;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:53,代码来源:page8.ts


示例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);
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:13,代码来源:timer-tests.ts


示例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!");
};
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:15,代码来源:timer-tests.ts



注:本文中的tns-core-modules/timer.setTimeout函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript trace.addCategories函数代码示例发布时间:2022-05-25
下一篇:
TypeScript timer.setInterval函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap