• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript backburner.scheduleOnce函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript backburner.throttle函数代码示例发布时间:2022-05-25
下一篇:
TypeScript backburner.schedule函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap