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


TypeScript backburner.schedule函數代碼示例

本文整理匯總了TypeScript中backburner.schedule函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript schedule函數的具體用法?TypeScript schedule怎麽用?TypeScript schedule使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了schedule函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

QUnit.test('schedule - DEBUG flag enables stack tagging', function(assert) {
  let bb = new Backburner(['one']);

  bb.schedule('one', () => {});
  if (!bb.currentInstance) {
    throw new Error('bb has no instance');
  }

  assert.ok(bb.currentInstance && !bb.currentInstance.queues.one.stackFor(0), 'No stack is recorded');

  bb.DEBUG = true;

  bb.schedule('one', () => {});

  if (new Error().stack) { // workaround for CLI runner :(
    assert.expect(4);
    let stack = bb.currentInstance && bb.currentInstance.queues.one.stackFor(1);
    assert.ok(typeof stack === 'string', 'A stack is recorded');

    let onError = function(error, errorRecordedForStack) {
      assert.ok(errorRecordedForStack, 'errorRecordedForStack passed to error function');
      assert.ok(errorRecordedForStack.stack, 'stack is recorded');
    };

    bb = new Backburner(['errors'], { onError });
    bb.DEBUG = true;

    bb.run(() => {
      bb.schedule('errors', () => {
        throw new Error('message!');
      });
    });
  }
});
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:34,代碼來源:debug-test.ts

示例2: resetError

  bb.run(function() {
    bb.schedule('one', target1, method, arg1);
    bb.schedule('two', target2, method, arg1, arg2);

    debugInfo = bb.getDebugInfo();

    resetError();

    assert.deepEqual(debugInfo.instanceStack,
    [
      {
        one: [
          {
            args: [arg1],
            method,
            stack: oneStack,
            target: target1
          }
        ],
        two: [
          {
            args: [arg1, arg2],
            method,
            stack: twoStack,
            target: target2
          }
        ]
      }
    ]
    , 'debugInfo is output');
  });
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:31,代碼來源:debug-info-test.ts

示例3:

  bb.run(() => {
    bb.schedule('render', method);
    bb.schedule('afterRender', method);

    debugInfo = bb.currentInstance && bb.currentInstance._getDebugInfo(bb.DEBUG);

    assert.deepEqual(debugInfo, {
      render: [
        {
          target: null,
          method,
          args: undefined,
          stack: renderStack
        }
      ],
      afterRender: [
        {
          target: null,
          method,
          args: undefined,
          stack: afterRenderStack
        }
      ]
    });
  });
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:25,代碼來源:defer-debug-info-test.ts

示例4: increment

    function increment() {
      if (++count < 3) {
        bb.schedule('one', increment);
      }

      if (count === 3) {

        bb.schedule('one', increment);
      }
    }
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:10,代碼來源:queue-test.ts

示例5:

 bb.run(() => {
   items.push(0);
   bb.schedule('one', () => items.push(4));
   bb.join(() => {
     items.push(1);
     bb.schedule('one', () => items.push(5));
     items.push(2);
   });
   bb.schedule('one', () => items.push(6));
   items.push(3);
 });
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:11,代碼來源:join-test.ts

示例6: function

QUnit.test('customized flushing - precedence is rechecked upon each flush', function(assert) {
  assert.step('start');

  let deferredFlush;

  let bb = new Backburner(
    [
      'zomg',
      'render',
      'afterRender'
    ],
    {
      flush(queueName, flush) {
        if (deferredFlush === undefined && queueName === 'render') {
          deferredFlush = flush;
        } else {
          flush();
        }
      }
    }
  );

  bb.schedule('zomg', null, () => {
    assert.step('running zomg');
  });

  bb.schedule('render', null, () => {
    assert.step('running render');
  });

  bb.schedule('afterRender', null, () => {
    assert.step('running afterRender');
  });

  return escapeCurrentMicrotaskQueue()
    .then(() => {
      bb.schedule('zomg', null, () => {
        assert.step('running zomg 2');
      });

      deferredFlush();
    })
    .then(escapeCurrentMicrotaskQueue)
    .then(() => {
      assert.verifySteps([
        'start',
        'running zomg',
        'running zomg 2',
        'running render',
        'running afterRender',
      ]);
    });
});
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:53,代碼來源:autorun-test.ts

示例7: function

  bb.run(function() {
    assert.equal(step++, 0, '0');

    bb.schedule('two', null, function() {
      assert.equal(step++, 1, '1');

      bb.schedule('one', null, function() {
        assert.equal(step++, 3, '3');
      });
    });

    bb.schedule('two', null, function() {
      assert.equal(step++, 2, '2');
    });
  });
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:15,代碼來源:queue-test.ts

示例8:

      return Promise.resolve().then(() => {
        actual.push('third');

        bb.schedule('actions', () => {
          actual.push('action3');
        });
      });
開發者ID:ebryn,項目名稱:backburner.js,代碼行數:7,代碼來源:autorun-test.ts


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