当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript backburner.scheduleOnce函数代码示例

本文整理汇总了TypeScript中backburner.scheduleOnce函数的典型用法代码示例。如果您正苦于以下问题:TypeScript scheduleOnce函数的具体用法?TypeScript scheduleOnce怎么用?TypeScript scheduleOnce使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scheduleOnce函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

  bb.run(() => {
    let timer = bb.scheduleOnce('action', fn);

    assert.equal(wasCalled, 0);

    bb.cancel(timer);
    bb.scheduleOnce('action', fn);

    assert.equal(wasCalled, 0);
  });
开发者ID:ebryn,项目名称:backburner.js,代码行数:10,代码来源:cancel-test.ts

示例2: function

QUnit.test('We can use a custom next', function(assert) {
  assert.expect(1);
  let done = assert.async();

  let customNextWasUsed = false;
  let bb = new Backburner(['one'], {
    _buildPlatform(flush) {
      return {
        setTimeout() {
          throw new TypeError('NOT IMPLEMENTED');
        },
        clearTimeout(timer) {
          return clearTimeout(timer);
        },
        next() {
          // next is used for the autorun
          customNextWasUsed = true;
          return setTimeout(flush);
        },
        clearNext() { },
        now() { return Date.now(); },
        isFakePlatform: true
      };
    }
  });

  bb.scheduleOnce('one', () => {
    assert.ok(customNextWasUsed , 'custom later was used');
    done();
  });
});
开发者ID:ebryn,项目名称:backburner.js,代码行数:31,代码来源:configurable-timeout-test.ts

示例3: function

 bb.run(() => {
   bb.scheduleOnce('one', {zomg: 'hi'}, function(a, b, c) {
     assert.equal(this.zomg, 'hi', 'the target was properly set');
     assert.equal(a, 1, 'the first arguments was passed in');
     assert.equal(b, 2, 'the second arguments was passed in');
     assert.equal(c, 3, 'the third arguments was passed in');
     functionWasCalled = true;
   }, 1, 2, 3);
 });
开发者ID:ebryn,项目名称:backburner.js,代码行数:9,代码来源:defer-once-test.ts

示例4: function

QUnit.test('properly cancel items which are added during flush', function(assert) {
  let bb = new Backburner(['zomg'], {
    // This is just a place holder for now, but somehow the system needs to
    // know to when to stop
    mustYield() {
      return true; // yield after each step, for now.
    },

    _buildPlatform: buildFakePlatform
  });

  let fooCalled = 0;
  let barCalled = 0;

  let obj1 = {
    foo() {
      fooCalled++;
    }
  };

  let obj2 = {
    bar() {
      barCalled++;
    }
  };

  bb.scheduleOnce('zomg', obj1, 'foo');
  bb.scheduleOnce('zomg', obj1, 'foo');
  bb.scheduleOnce('zomg', obj2, 'bar');
  bb.scheduleOnce('zomg', obj2, 'bar');

  platform.flushSync();

  let timer1 = bb.scheduleOnce('zomg', obj1, 'foo');
  let timer2 = bb.scheduleOnce('zomg', obj2, 'bar');
  bb.cancel(timer1);
  bb.cancel(timer2);

  platform.flushSync();
  platform.flushSync();
  platform.flushSync();

  assert.equal(fooCalled, 1, 'fooCalled');
  assert.equal(barCalled, 1, 'barCalled');

});
开发者ID:ebryn,项目名称:backburner.js,代码行数:46,代码来源:multi-turn-test.ts

示例5: Error

 bb.run(() => {
   bb.scheduleOnce('errors', () => {
     throw new Error('QUnit.test error');
   });
 });
开发者ID:ebryn,项目名称:backburner.js,代码行数:5,代码来源:defer-once-test.ts

示例6:

 bb.run(() => {
   bb.scheduleOnce('one', argObj, deferMethod, 1);
   bb.scheduleOnce('two', argObj, scheduleMethod);
 });
开发者ID:ebryn,项目名称:backburner.js,代码行数:4,代码来源:defer-once-test.ts

示例7: scheduleMethod

 function scheduleMethod() {
   bb.scheduleOnce('one', argObj, deferMethod, 2);
 }
开发者ID:ebryn,项目名称:backburner.js,代码行数:3,代码来源:defer-once-test.ts

示例8:

 bb.run(() => {
   bb.scheduleOnce('one', () => {
     assert.ok(!functionWasCalled, 'function was not called');
     assert.ok(customClearTimeoutWasUsed, 'custom clearTimeout was used');
   });
 });
开发者ID:ebryn,项目名称:backburner.js,代码行数:6,代码来源:configurable-timeout-test.ts


注:本文中的backburner.scheduleOnce函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。