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


TypeScript Tyr.sleepUntil方法代码示例

本文整理汇总了TypeScript中tyranid.Tyr.sleepUntil方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tyr.sleepUntil方法的具体用法?TypeScript Tyr.sleepUntil怎么用?TypeScript Tyr.sleepUntil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tyranid.Tyr的用法示例。


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

示例1: it

    it('should let you define custom events', async () => {
      let count = 0;

      User.on({
        type: 'myCustomEvent',
        async handler(event) {
          count++;
        }
      });

      await User.fire({
        type: 'myCustomEvent'
      });

      await Tyr.sleepUntil(() => !!count);
    });
开发者ID:tyranid-org,项目名称:tyranid,代码行数:16,代码来源:event.test.ts

示例2: it

      it('should support subscriptions', async () => {
        const cleanup = () =>
          Promise.all([
            Location.remove({ query: {} }),
            Subscription.remove({ query: {} })
          ]);

        await cleanup();

        try {
          await page.evaluate(`
const Location = Tyr.byName.location;
Location.subscribe({});
window._gotChangeEvent = false;
window._gotRemoveEvent = false;
Location.on({ type: 'change', handler(event) { window._gotChangeEvent = true; } });
Location.on({ type: 'update', handler(event) { window._gotUpdateEvent = true; } });
Location.on({ type: 'insert', handler(event) { window._gotInsertEvent = true; } });
Location.on({ type: 'remove', handler(event) { window._gotRemoveEvent = true; } });`);

          await Tyr.sleepUntil(async () =>
            Subscription.exists({
              query: { u: 1, c: Location.id }
            })
          );

          await Location.save({ name: 'Yosemite Valley' });

          await Tyr.sleepUntil(async () =>
            page.evaluate(
              `Tyr.byName.location.values.length === 1 && window._gotChangeEvent && window._gotInsertEvent && !window._gotUpdateEvent`
            )
          );

          await page.evaluate(`
          window._gotChangeEvent = false;
          window._gotUpdateEvent = false;
          window._gotInsertEvent = false;`);
          let location = await Location.findOne({
            query: { name: 'Yosemite Valley' }
          });
          location!.name = 'Yosemite Valley 2';
          await location!.$save();

          await Tyr.sleepUntil(async () =>
            page.evaluate(
              `Tyr.byName.location.values.length === 1 && Tyr.byName.location.values[0].name === 'Yosemite Valley 2' && window._gotChangeEvent && !window._gotInsertEvent && window._gotUpdateEvent`
            )
          );

          location = await Location.findOne({
            query: { name: 'Yosemite Valley 2' }
          });
          await location!.$remove();

          await Tyr.sleepUntil(async () =>
            page.evaluate(
              'Tyr.byName.location.values.length === 0 && window._gotRemoveEvent'
            )
          );
        } finally {
          await cleanup();
        }
      });
开发者ID:tyranid-org,项目名称:tyranid,代码行数:64,代码来源:express.test.ts


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