本文整理匯總了TypeScript中backburner.hasTimers函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript hasTimers函數的具體用法?TypeScript hasTimers怎麽用?TypeScript hasTimers使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了hasTimers函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
QUnit.test('cancelTimers', function(assert) {
assert.expect(8);
let done = assert.async();
let bb = new Backburner(['one']);
let laterWasCalled = false;
let debounceWasCalled = false;
let throttleWasCalled = false;
let timer1 = bb.later(() => laterWasCalled = true, 0);
let timer2 = bb.debounce(() => debounceWasCalled = true, 0);
let timer3 = bb.throttle(() => throttleWasCalled = true, 0, false);
assert.ok(timer1, 'Timer object was returned');
assert.ok(timer2, 'Timer object was returned');
assert.ok(timer3, 'Timer object was returned');
assert.ok(bb.hasTimers(), 'bb has scheduled timer');
bb.cancelTimers();
setTimeout(function() {
assert.ok(!bb.hasTimers(), 'bb has no scheduled timer');
assert.ok(!laterWasCalled, 'later function was not called');
assert.ok(!debounceWasCalled, 'debounce function was not called');
assert.ok(!throttleWasCalled, 'throttle function was not called');
done();
}, 100);
});
示例2: setTimeout
setTimeout(function() {
assert.ok(!bb.hasTimers(), 'bb has no scheduled timer');
assert.ok(!laterWasCalled, 'later function was not called');
assert.ok(!debounceWasCalled, 'debounce function was not called');
assert.ok(!throttleWasCalled, 'throttle function was not called');
done();
}, 100);
示例3: done
bb.schedule('ohai', null, () => {
assert.ok(!bb.hasTimers(), 'Initially there are no timers');
timer = bb.later('ohai', () => {});
assert.ok(bb.hasTimers(), 'hasTimers checks timers');
bb.cancel(timer);
assert.ok(!bb.hasTimers(), 'Timers are cleared');
timer = bb.debounce(target, 'fn', 200);
assert.ok(bb.hasTimers(), 'hasTimers checks debouncees');
bb.cancel(timer);
assert.ok(!bb.hasTimers(), 'Timers are cleared');
timer = bb.throttle(target, 'fn', 200);
assert.ok(bb.hasTimers(), 'hasTimers checks throttlers');
bb.cancel(timer);
assert.ok(!bb.hasTimers(), 'Timers are cleared');
done();
});
示例4: setTimeout
setTimeout(() => {
assert.ok(!bb.hasTimers(), 'The all timers are cleared');
done();
});
示例5: SET_TIMEOUT
SET_TIMEOUT(() => {
assert.ok(!bb.hasTimers(), 'The all timers are cleared');
done();
});