本文整理汇总了TypeScript中@ember/runloop.getCurrentRunLoop函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getCurrentRunLoop函数的具体用法?TypeScript getCurrentRunLoop怎么用?TypeScript getCurrentRunLoop使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getCurrentRunLoop函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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();
}
});
示例2: 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);
}
});
示例3: 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);
示例4: renderSettled
export function renderSettled() {
if (renderSettledDeferred === null) {
renderSettledDeferred = RSVP.defer();
// if there is no current runloop, the promise created above will not have
// a chance to resolve (because its resolved in backburner's "end" event)
if (!getCurrentRunLoop()) {
// ensure a runloop has been kicked off
backburner.schedule('actions', null, K);
}
}
return renderSettledDeferred.promise;
}