本文整理匯總了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);
}
示例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: 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!");
};
示例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!");
};
示例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");
}
示例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!");
};
示例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!");
};
示例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!");
};
示例9:
let id = timer.setTimeout(() => {
completed = true;
timer.clearTimeout(id);
});