當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript timer.clearTimeout函數代碼示例

本文整理匯總了TypeScript中tns-core-modules/timer.clearTimeout函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript clearTimeout函數的具體用法?TypeScript clearTimeout怎麽用?TypeScript clearTimeout使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了clearTimeout函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例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: 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

示例4: test_setTimeout_callbackShouldBeCleared

export function test_setTimeout_callbackShouldBeCleared() {
    let completed = false;

    // >> timer-set-fifty
    const id = timer.setTimeout(() => {
        // >> (hide)
        completed = true;
        // << (hide)
    }, 50);

    //// Clear timeout with specified id.
    timer.clearTimeout(id);

    // << timer-set-fifty

    TKUnit.wait(0.060);
    timer.clearTimeout(id);
    TKUnit.assert(!completed, "Callback should be cleared when clearTimeout() is executed for specified id!");
};
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:19,代碼來源:timer-tests.ts

示例5: 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

示例6: 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

示例7: test_setTimeout

export function test_setTimeout() {
    let completed: boolean;

    // >> timer-set-zero
    const id = timer.setTimeout(() => {
        // >> (hide)
        completed = true;
        // << (hide)
    });
    // << timer-set-zero

    TKUnit.waitUntilReady(() => completed, 0.5, false);
    timer.clearTimeout(id);
    TKUnit.assert(completed, "Callback should be called!");
};
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:15,代碼來源:timer-tests.ts

示例8: test_setTimeout_extraArgs

export function test_setTimeout_extraArgs() {
    let completed: boolean;
    let rnd: number = Math.random();

    // >> timer-set-zero-args
    const id = timer.setTimeout((arg) => {
        // >> (hide)
        completed = rnd === arg;
        // << (hide)
    }, 0, rnd);
    // << timer-set-zero-args

    TKUnit.waitUntilReady(() => completed, 0.5, false);
    timer.clearTimeout(id);
    TKUnit.assert(completed, "Callback called with expected argument!");
};
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:16,代碼來源:timer-tests.ts

示例9:

 let id = timer.setTimeout(() => {
     completed = true;
     timer.clearTimeout(id);
 });
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:4,代碼來源:timer-tests.ts


注:本文中的tns-core-modules/timer.clearTimeout函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。