當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript runloop.getCurrentRunLoop函數代碼示例

本文整理匯總了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();
    }
  });
開發者ID:jacobq,項目名稱:ember.js,代碼行數:15,代碼來源:run-loop.ts

示例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);
    }
  });
開發者ID:cibernox,項目名稱:ember.js,代碼行數:27,代碼來源:run-loop.ts

示例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);
開發者ID:cibernox,項目名稱:ember.js,代碼行數:12,代碼來源:run.ts

示例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;
}
開發者ID:habdelra,項目名稱:ember.js,代碼行數:13,代碼來源:renderer.ts


注:本文中的@ember/runloop.getCurrentRunLoop函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。