本文整理汇总了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);
});