當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。