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


TypeScript task.forkTask函数代码示例

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


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

示例1: test

    test('writing unblocks reads', function* () {
      const chan: Q.Chan<number> = yield Q.newChan;
      yield T.forkTask(T.apSecond(T.delay(20), Q.writeChan(chan, 1)));
      const r: P.Either<void, number> = yield compete(T.delay(50), Q.readChan(chan));
      assert.ok(P.isRight(r));

      return T.pure(void 0);
    });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:chan.ts

示例2:

function spawn<W, I>(
  settings: ReaperSettings<W, I>,
  stateRef: R.Ref<State<W>>,
  tidRef: R.Ref<T.Fiber<void> | undefined>
): T.Task<void> {
  return T.forkTask(reaper(settings, stateRef, tidRef))
    .chain(fib => R.writeRef(tidRef, fib));
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:8,代码来源:reaper.ts

示例3:

 return T.co(function* () {
   const baton: AV.AVar<null> = yield AV.newEmptyAVar;
   yield T.forkTask(T.forever(T.co(function* () {
     yield AV.takeAVar(baton);
     yield T.apathize(settings.action);
     return T.delay(settings.frequency);
   })));
   return T.pure(AV.putAVar(baton, null));
 });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:9,代码来源:debounce.ts

示例4: co

  return co(function* () {
    let needsRunning: AVar<null> = yield newEmptyAVar;
    let responseVar0: AVar<A> = yield newEmptyAVar;
    let currRef: Ref<Either<AVar<A>, A>> = yield newRef(left(responseVar0));
    function loop(responseVar: AVar<A>, ma: Maybe<A>): Task<void> {
      return co(function* () {
        yield takeAVar(needsRunning);
        const a: A = yield maybe(set.task, identity, applyMaybe(modify, ma)) as Task<A>;
        yield writeRef(currRef, right(a));
        yield putAVar(responseVar, a);
        yield delay(set.delay);
        const responseVar_: AVar<A> = yield newEmptyAVar;
        yield writeRef(currRef, left(responseVar_));
        return loop(responseVar_, just(a));
      });
    }
    yield forkTask(loop(responseVar0, nothing));

    return pure(readRef(currRef).chain(mv => {
      return isLeft(mv)  ? putAVar(needsRunning, null).chain(() => readAVar(mv.value))
        /* otherwise */  : pure(mv.value);
    }));
  });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:23,代码来源:auto-update.ts

示例5:

 return AV.newEmptyAVar.chain(avar =>
   T.forkTask(T.ensure(t, AV.putAVar(avar, void 0))).chain(fib =>
     T.delay(10).map(() => [fib, avar] as [T.Fiber<A>, AV.AVar<void>])
   )
开发者ID:syaiful6,项目名称:jonggrang,代码行数:4,代码来源:utils.ts

示例6:

 AV.newEmptyAVar.chain(avar =>
   T.forkTask(T.delay(15).then(AV.putAVar(avar, 1)))
     .then(AV.takeAVar(avar))
开发者ID:syaiful6,项目名称:jonggrang,代码行数:3,代码来源:avar.ts

示例7: Error

 .chain(av =>
   T.forkTask(
     AV.withAVar(av, () => T.delay(100)))
   .chain(fib =>
     T.killFiber(new Error('kill withAVar action'), fib))
   .then(AV.takeAVar(av)))
开发者ID:syaiful6,项目名称:jonggrang,代码行数:6,代码来源:avar.ts

示例8:

 ).chain(() =>
   T.forkTask(T.node(null, path, permission, FS.chmod))
开发者ID:syaiful6,项目名称:jonggrang,代码行数:2,代码来源:run.ts


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