本文整理匯總了TypeScript中tns-core-modules/timer.clearInterval函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript clearInterval函數的具體用法?TypeScript clearInterval怎麽用?TypeScript clearInterval使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了clearInterval函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: done
const id = timer.setInterval(() => {
// >> (hide)
const end = TKUnit.time();
timer.clearInterval(id);
done(end - start > 150 ? new Error('setInterval too slow.') : null);
// << (hide)
timer.clearInterval(id);
}, 50);
示例2: test_clearInterval_immediatelyAfterCreate
export function test_clearInterval_immediatelyAfterCreate() {
let completed = false;
const id = timer.setInterval(() => {
completed = true;
});
timer.clearInterval(id);
TKUnit.wait(0.05);
TKUnit.assert(!completed, "Callback should not be called");
}
示例3: done
const id = timer.setInterval(() => {
// >> (hide)
counter++;
if (counter === expected) {
const end = TKUnit.time();
timer.clearInterval(id);
const time = end - start;
done(time > timeLimit ? new Error(`setInterval too slow. Actual time: ${time} timelimit: ${timeLimit}`) : null);
}
// << (hide)
}, 50);