• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript operators.concatAll函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: expect

 constructorZone2.run(() => {
   const highOrder = observable1.pipe(map((v: any) => {
     expect(Zone.current.name).toEqual(constructorZone2.name);
     return of(v + 1);
   }));
   concatObservable = highOrder.pipe(concatAll());
 });
开发者ID:angular,项目名称:zone.js,代码行数:7,代码来源:rxjs.Observable.concat.spec.ts


示例2: it

 it('should handle an Observable as the only value', () => {
   const source = of<Observable<string>>(
     of<string>('a', 'b', 'c', rxTestScheduler),
     rxTestScheduler
   );
   const result = source.pipe(concatAll());
   expectObservable(result).toBe('(abc|)');
 });
开发者ID:DallanQ,项目名称:rxjs,代码行数:8,代码来源:of-spec.ts


示例3: concatMap

 concatMap((check: CanActivate) => {
   return from([
            fireChildActivationStart(check.route.parent, forwardEvent),
            fireActivationStart(check.route, forwardEvent),
            runCanActivateChild(futureSnapshot, check.path, moduleInjector),
            runCanActivate(futureSnapshot, check.route, moduleInjector)
          ])
       .pipe(concatAll(), first(result => {
               return result !== true;
             }, true as boolean | UrlTree));
 }),
开发者ID:Cammisuli,项目名称:angular,代码行数:11,代码来源:check_guards.ts


示例4: concatAll1

 concatAll1() {
   // emit a value every 2 seconds
   const source = interval(2000);
   const example = source.pipe(
     // for demonstration, add 10 to and return as observable
     map(val => of(val + 10)),
     // merge values from inner observable
     concatAll()
   );
   // output: 'Example with Basic Observable 10', 'Example with Basic Observable 11'...
   const subscribe = example.subscribe(val =>
     console.log('Example with Basic Observable:', val)
   );
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:14,代码来源:aggregate.service.ts


示例5: concatAll2

  concatAll2() {
    // create and resolve basic promise
    const samplePromise = val => new Promise(resolve => resolve(val));
    // emit a value every 2 seconds
    const source = interval(2000);

    const example = source.pipe(
      map(val => samplePromise(val)),
      // merge values from resolved promise
      concatAll()
    );
    // output: 'Example with Promise 0', 'Example with Promise 1'...
    const subscribe = example.subscribe(val =>
      console.log('Example with Promise:', val)
    );
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:16,代码来源:aggregate.service.ts


示例6: mergeMap

    mergeMap((timing) => {
      log.warn("Buffer: Running garbage collector");
      const buffered = bufferingQueue.getBuffered();
      let cleanedupRanges =
        selectGCedRanges(timing.currentTime, buffered, GC_GAP_CALM);

      // more aggressive GC if we could not find any range to clean
      if (cleanedupRanges.length === 0) {
        cleanedupRanges =
          selectGCedRanges(timing.currentTime, buffered, GC_GAP_BEEFY);
      }

      log.debug("Buffer: GC cleaning", cleanedupRanges);
      return observableFrom(
        cleanedupRanges.map(({ start, end }) => bufferingQueue.removeBuffer(start, end))
      ).pipe(concatAll());
    })
开发者ID:canalplus,项目名称:rx-player,代码行数:17,代码来源:force_garbage_collection.ts


示例7: concatAll3

  concatAll3() {
    const obs1 = interval(1000).pipe(take(5));
    const obs2 = interval(500).pipe(take(2));
    const obs3 = interval(2000).pipe(take(1));
    // emit three observables
    const source = of(obs1, obs2, obs3);
    // subscribe to each inner observable in order when previous completes
    const example = source.pipe(concatAll());
    /*
      output: 0,1,2,3,4,0,1,0
      How it works...
      Subscribes to each inner observable and emit values, when complete subscribe to next
      obs1: 0,1,2,3,4 (complete)
      obs2: 0,1 (complete)
      obs3: 0 (complete)
    */

    const subscribe = example.subscribe(val => console.log(val));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:19,代码来源:aggregate.service.ts


示例8: of

export function waitForMap<A, B>(
    obj: {[k: string]: A}, fn: (k: string, a: A) => Observable<B>): Observable<{[k: string]: B}> {
  if (Object.keys(obj).length === 0) {
    return of ({});
  }

  const waitHead: Observable<B>[] = [];
  const waitTail: Observable<B>[] = [];
  const res: {[k: string]: B} = {};

  forEach(obj, (a: A, k: string) => {
    const mapped = fn(k, a).pipe(map((r: B) => res[k] = r));
    if (k === PRIMARY_OUTLET) {
      waitHead.push(mapped);
    } else {
      waitTail.push(mapped);
    }
  });

  // Closure compiler has problem with using spread operator here. So just using Array.concat.
  return of .apply(null, waitHead.concat(waitTail)).pipe(concatAll(), lastValue(), map(() => res));
}
开发者ID:Cammisuli,项目名称:angular,代码行数:22,代码来源:collection.ts


示例9: clearBuffer


//.........这里部分代码省略.........
 * @param {QueuedSourceBuffer} qSourceBuffer
 * @param {Number} position - The current position
 * @param {Number} maxBufferBehind
 * @param {Number} maxBufferAhead
 * @returns {Observable}
 */
function clearBuffer(
  qSourceBuffer : QueuedSourceBuffer<unknown>,
  position : number,
  maxBufferBehind : number,
  maxBufferAhead : number
) : Observable<never> {
  if (!isFinite(maxBufferBehind) && !isFinite(maxBufferAhead)) {
    return EMPTY;
  }

  const cleanedupRanges : Array<{
    start : number;
    end: number;
  }> = [];
  const { innerRange, outerRanges } = getInnerAndOuterTimeRanges(
    qSourceBuffer.getBuffered(),
    position
  );

  const collectBufferBehind = () => {
    if (!isFinite(maxBufferBehind)) {
      return ;
    }

    // begin from the oldest
    for (let i = 0; i < outerRanges.length; i++) {
      const outerRange = outerRanges[i];
      if (position - maxBufferBehind >= outerRange.end) {
        cleanedupRanges.push(outerRange);
      }
      else if (
        position >= outerRange.end &&
        position - maxBufferBehind > outerRange.start &&
        position - maxBufferBehind < outerRange.end
      ) {
        cleanedupRanges.push({
          start: outerRange.start,
          end: position - maxBufferBehind,
        });
      }
    }
    if (innerRange) {
      if (position - maxBufferBehind > innerRange.start) {
        cleanedupRanges.push({
          start: innerRange.start,
          end: position - maxBufferBehind,
        });
      }
    }
  };

  const collectBufferAhead = () => {
    if (!isFinite(maxBufferAhead)) {
      return ;
    }

    // begin from the oldest
    for (let i = 0; i < outerRanges.length; i++) {
      const outerRange = outerRanges[i];
      if (position + maxBufferAhead <= outerRange.start) {
        cleanedupRanges.push(outerRange);
      }
      else if (
        position <= outerRange.start &&
        position + maxBufferAhead < outerRange.end &&
        position + maxBufferAhead > outerRange.start
      ) {
        cleanedupRanges.push({
          start: position + maxBufferAhead,
          end: outerRange.end,
        });
      }
    }
    if (innerRange) {
      if (position + maxBufferAhead < innerRange.end) {
        cleanedupRanges.push({
          start: position + maxBufferAhead,
          end: innerRange.end,
        });
      }
    }
  };

  collectBufferBehind();
  collectBufferAhead();
  const clean$ = observableFrom(
    cleanedupRanges.map((range) => {
      log.debug("GC: cleaning range from SourceBuffer", range);
      return qSourceBuffer.removeBuffer(range.start, range.end);
    })
  ).pipe(concatAll(), ignoreElements());

  return clean$;
}
开发者ID:canalplus,项目名称:rx-player,代码行数:101,代码来源:garbage_collector.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript operators.concatMap函数代码示例发布时间:2022-05-25
下一篇:
TypeScript operators.concat函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap