當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript task.forInPar函數代碼示例

本文整理匯總了TypeScript中@jonggrang/task.forInPar函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript forInPar函數的具體用法?TypeScript forInPar怎麽用?TypeScript forInPar使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了forInPar函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('storage.destroyAllOfAuthId should only delete relevant Auth Id', function* () {
    const master: Session = yield generateSession(HasAuthId.HAS_AUTH_ID);
    const authId = master.authId as string;

    const preslaves: Session[] = yield (replicateA(20, generateSession(HasAuthId.HAS_AUTH_ID))
      .concat(replicateA(20, generateSession(HasAuthId.NO_AUTH_ID)))
    );
    const slaves = preslaves.map(x => createSession(x.id, authId, x.data, x.createdAt, x.accessedAt));

    const others: Session[] = yield (replicateA(20, generateSession(HasAuthId.HAS_AUTH_ID))
      .concat(replicateA(20, generateSession(HasAuthId.NO_AUTH_ID)))
    );
    const allS = [master].concat(slaves, others);

    // insert session
    yield T.forInPar_([master].concat(preslaves, others), x => run(storage.insert(x)));
    yield T.forInPar_(slaves, x => run(storage.replace(x)));

    const xs: (Session | null)[] = yield T.forInPar(allS, x => run(storage.get(x.id)));
    assert.deepEqual(xs, allS);
    yield run(storage.destroyAllOfAuthId(authId));
    const ys: (Session | null)[] = yield T.forInPar(allS, x => run(storage.get(x.id)));
    const xxs = new Array(slaves.length + 1).fill(null);
    assert.deepEqual(ys, xxs.concat(others as any));
    return T.pure(true);
  });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:26,代碼來源:storage-test.ts

示例2: update

    function update(
      state: AppState<M, Q, S>,
      action: AppAction<M, Q, S, I>
    ): T.Task<AppState<M, Q, S>> {
      let next: Transition<M, S, I>,
        needsRender: boolean,
        nextState: AppState<M, Q, S>,
        appChange: AppChange<S, I>;
      switch (action.tag) {
        case AppActionType.INTERPRET:
          return state.interpret.loop(action.payload)
            .chain(ni => {
              return T.pure(S.assign({}, state, {
                interpret: ni
              }));
            });

        case AppActionType.ACTION:
          next = app.update(state.model, action.payload);
          needsRender = state.needsRender || state.model !== next.model;
          nextState = S.assign({}, state, {
            needsRender,
            model: next.model
          });
          appChange = { old: state.model, action: action.payload, model: nextState.model };
          return onChange(appChange).then(T.forInPar(next.effects, pushEffect)).map(() => nextState);

        case AppActionType.RESTORE:
          needsRender = state.needsRender || state.model !== action.payload;
          nextState = S.assign({}, state, { needsRender, model: action.payload });
          return T.pure(nextState);
      }
    }
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:33,代碼來源:genjer.ts

示例3: newRef

 return newRef(int).chain(ref => {
   return T.forInPar(subs, q => {
     return readRef(ref)
       .chain(k => k.loop(E.right(q)))
       .chain(nq => writeRef(ref, nq));
   }).then(readRef(ref));
 });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:7,代碼來源:genjer.ts

示例4:

 ).chain(it2 => {
   return T.forInPar(app.init.effects, pushEffect)
     .chain(() => {
       let st: AppState<M, Q, S> = { snabbdom
                                   , interpret: it2
                                   , needsRender: false
                                   , model: app.init.model };
       return T.pure({ update, commit, init: st});
     });
 })
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:10,代碼來源:genjer.ts

示例5:

export function witherPar<A, B>(xs: A[], fn: (_: A, i: number) => T.Task<P.Maybe<B>>): T.Task<B[]> {
  return T.forInPar(xs, fn).map(P.catMaybes);
}
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:3,代碼來源:async.ts

示例6: newQSem

 : newQSem(n).chain(qsem => T.forInPar(xs, (x, i) => withQSem(qsem, f(x, i))));
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:1,代碼來源:async.ts

示例7: cb

 .chain(sbs => T.forInPar(S.recordValues(sbs.cbs), cb => cb(ac)))
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:1,代碼來源:genjer.ts


注:本文中的@jonggrang/task.forInPar函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。