本文整理汇总了TypeScript中@ember/runloop.hasScheduledTimers函数的典型用法代码示例。如果您正苦于以下问题:TypeScript hasScheduledTimers函数的具体用法?TypeScript hasScheduledTimers怎么用?TypeScript hasScheduledTimers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hasScheduledTimers函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setTimeout
hooks.afterEach(function(assert) {
if (getCurrentRunLoop() || hasScheduledTimers()) {
let done = assert.async();
// use a setTimeout to allow the current run loop to flush via autorun
setTimeout(() => {
// increment expected assertion count for the assertions just below
if (assert['test'].expected !== null) {
assert['test'].expected += 2;
}
// if it is _still_ not completed, we have a problem and the test should be fixed
assert.ok(
!hasScheduledTimers(),
'Ember run should not have scheduled timers at end of test'
);
assert.ok(!getCurrentRunLoop(), 'Should not be in a run loop at end of test');
// attempt to recover so the rest of the tests can run
while (getCurrentRunLoop()) {
end();
}
cancelTimers();
done();
}, 0);
}
});
示例2: setInterval
let watcher = setInterval(() => {
// If there are scheduled timers or we are inside of a run loop, keep polling
if (hasScheduledTimers() || getCurrentRunLoop()) {
return;
}
// Stop polling
clearInterval(watcher);
// Synchronously resolve the promise
resolve(event);
}, 5);
示例3: while
hooks.afterEach(function() {
let { assert } = QUnit.config.current;
if (getCurrentRunLoop()) {
assert.ok(false, 'Should not be in a run loop at end of test');
while (getCurrentRunLoop()) {
end();
}
}
if (hasScheduledTimers()) {
assert.ok(false, 'Ember run should not have scheduled timers at end of test');
cancelTimers();
}
});