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


TypeScript operators.concatAll函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。