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


TypeScript ref.readRef函数代码示例

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


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

示例1: 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

示例2: readRef

 .map(queue =>
   ({ push: (i: I) => queue.push({ tag: AppActionType.ACTION, payload: i }),
     snapshot: readRef(stateRef),
     restore: (s: S) => queue.push({ tag: AppActionType.RESTORE, payload: s }),
     subscribe: subscribe_,
     run: queue.run
   })
开发者ID:syaiful6,项目名称:jonggrang,代码行数:7,代码来源:genjer.ts

示例3: mkAutoUpdate

 return T.toPromise(T.co(function* () {
   const ref: R.Ref<number> = yield R.newRef(0);
   const update: T.Task<number> = R.modifyRef_(ref, i => [i + 1, i + 1]);
   const next: T.Task<number> = yield mkAutoUpdate({ delay: 100, task: update });
   yield T.forIn_(range(1, 11), i => {
     return next.chain(j => {
       assert.equal(i === j && i !== 1, false);
       return T.pure(void 0);
     });
   });
   yield T.delay(300);
   const last1: number = yield R.readRef(ref);
   yield T.delay(200);
   const last2: number = yield R.readRef(ref);
   assert.equal(last1, last2);
   return T.pure(void 0);
 }));
开发者ID:syaiful6,项目名称:jonggrang,代码行数:17,代码来源:auto-update.ts

示例4: loop

 .chain(st => {
   return R.readRef(queue)
     .chain(q2 => {
       if (q2.length === 0) {
         return R.writeRef(machine, st)
           .then(R.writeRef(queue, []));
       }
       return loop(st);
     });
 });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:10,代码来源:event-queue.ts

示例5: subscribe_

 function subscribe_(cb: (_: AppChange<S, I>) => T.Task<void>): T.Task<T.Task<void>> {
   return readRef(subsRef)
     .chain(sbs => {
       let nkey = sbs.fresh.toString();
       return writeRef(subsRef, S.assign({}, sbs, {
         fresh: sbs.fresh + 1,
         sbs: S.assign({}, sbs.cbs, {
           [nkey]: cb
         })
       })).map(v => remove(nkey));
     });
 }
开发者ID:syaiful6,项目名称:jonggrang,代码行数:12,代码来源:genjer.ts

示例6: withFdCache

 T.supervise(T.co(function* () {
   let fdRef: R.Ref<number> = yield R.newRef(-1);
   yield withFdCache(3000, getFd =>
     getFd(0)(path.join(__dirname, '..', 'package.json')).chain(fd =>
       R.writeRef(fdRef, (fd[0] as any).value))
   );
   let fd: number = yield R.readRef(fdRef);
   return T.attempt(T.node(null, fd, fs.readFile)).chain(mcont => {
     assert.ok(isLeft(mcont));
     return T.pure(void 0);
   });
 }))
开发者ID:syaiful6,项目名称:jonggrang,代码行数:12,代码来源:fd-cache.test.ts

示例7: 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

示例8:

 return T.co(function* () {
   yield self.addMockOperation({ tag: 'get', id: sessId });
   return RV.readRef(self.sessions).map(sessions => sessId in sessions ? sessions[sessId] : null);
 });
开发者ID:syaiful6,项目名称:jonggrang,代码行数:4,代码来源:utils.ts

示例9: status

function status(ms: MutableStatus): T.Task<Status> {
  return RV.readRef(ms);
}
开发者ID:syaiful6,项目名称:jonggrang,代码行数:3,代码来源:fd-cache.ts


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