本文整理匯總了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;
}