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


TypeScript rxjs.race函数代码示例

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


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

示例1: waitUntilWatchIsReady

export function waitUntilWatchIsReady(
  stream: NodeJS.EventEmitter,
  opts: IWatchOptions = {}
) {
  const buildOutput$ = new Rx.Subject<string>();
  const onDataListener = (data: Buffer) =>
    buildOutput$.next(data.toString('utf-8'));
  const onEndListener = () => buildOutput$.complete();
  const onErrorListener = (e: Error) => buildOutput$.error(e);

  stream.once('end', onEndListener);
  stream.once('error', onErrorListener);
  stream.on('data', onDataListener);

  return Rx.race(getWatchHandlers(buildOutput$, opts))
    .pipe(
      mergeMap(whenReady => whenReady),
      finalize(() => {
        stream.removeListener('data', onDataListener);
        stream.removeListener('end', onEndListener);
        stream.removeListener('error', onErrorListener);

        buildOutput$.complete();
      })
    )
    .toPromise();
}
开发者ID:cjcenizal,项目名称:kibana,代码行数:27,代码来源:watch.ts

示例2: it

  it('should race a single observable', () => {
    const e1 =  cold('---a-----b-----c----|');
    const e1subs =   '^                   !';
    const expected = '---a-----b-----c----|';

    const result = race(e1);

    expectObservable(result).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:10,代码来源:race-spec.ts

示例3: race2

 race2() {
   // Throws an error and ignores the other observables.
   const first = of('first').pipe(
     delay(100),
     map(_ => {
       throw 'error';
     })
   );
   const second = of('second').pipe(delay(200));
   const third = of('third').pipe(delay(300));
   //  nothing logged
   race(first, second, third).subscribe(val => console.log(val));
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:13,代码来源:conditional.service.ts

示例4: observableDefer

  return observableDefer(() => {
    log.debug("Init: Trying to call endOfStream");
    if (mediaSource.readyState !== "open") {
      log.debug("Init: MediaSource not open, cancel endOfStream");
      return observableOf(null);
    }

    const { sourceBuffers } = mediaSource;
    const updatingSourceBuffers = getUpdatingSourceBuffers(sourceBuffers);

    if (!updatingSourceBuffers.length) {
      log.info("Init: Triggering end of stream");
      mediaSource.endOfStream();
      return observableOf(null);
    }

    log.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");
    const updatedSourceBuffers$ = updatingSourceBuffers
      .map((sourceBuffer) => onUpdate$(sourceBuffer).pipe(take(1)));

    return observableRace(
      observableMerge(...updatedSourceBuffers$).pipe(takeLast(1)),
      onRemoveSourceBuffers$(sourceBuffers).pipe(take(1))
    ).pipe(mergeMap(() => {
      return triggerEndOfStream(mediaSource);
    }));
  });
开发者ID:canalplus,项目名称:rx-player,代码行数:27,代码来源:end_of_stream.ts


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