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


TypeScript operators.combineAll函數代碼示例

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


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

示例1: combineAll1

 combineAll1() {
   // emit every 1s, take 2
   const source = interval(1000).pipe(take(2));
   // map each emitted value from source to interval observable that takes 5 values
   const example = source.pipe(
     map(val => interval(1000).pipe(map(i => `Result (${val}): ${i}`), take(5)))
   );
   /*
     2 values from source will map to 2 (inner) interval observables that emit every 1s
     combineAll uses combineLatest strategy, emitting the last value from each
     whenever either observable emits a value
   */
   const combined = example.pipe(combineAll());
   /*
     output:
     ["Result (0): 0", "Result (1): 0"]
     ["Result (0): 1", "Result (1): 0"]
     ["Result (0): 1", "Result (1): 1"]
     ["Result (0): 2", "Result (1): 1"]
     ["Result (0): 2", "Result (1): 2"]
     ["Result (0): 3", "Result (1): 2"]
     ["Result (0): 3", "Result (1): 3"]
     ["Result (0): 4", "Result (1): 3"]
     ["Result (0): 4", "Result (1): 4"]
   */
   const subscribe = combined.subscribe(val => console.log(val));
 }
開發者ID:zwvista,項目名稱:SampleMisc,代碼行數:27,代碼來源:combining.service.ts

示例2: of

 observable1 = constructorZone1.run(() => {
   const source = of(1, 2);
   const highOrder = source.pipe(map((src: any) => {
     expect(Zone.current.name).toEqual(constructorZone1.name);
     return of(src);
   }));
   return highOrder.pipe(combineAll());
 });
開發者ID:angular,項目名稱:zone.js,代碼行數:8,代碼來源:rxjs.Observable.combine.spec.ts

示例3: it

it('should infer correctly with the projector', () => {
  const o = of([1, 2, 3]).pipe(combineAll((values: number) => ['x', 'y', 'z'])); // $ExpectType Observable<string[]>
});
開發者ID:jaychsu,項目名稱:RxJS,代碼行數:3,代碼來源:combineAll-spec.ts

示例4: higherOrder

export function combineAll<T, R>(this: Observable<ObservableInput<T>>, project?: (...values: Array<T>) => R): Observable<R> {
  return higherOrder(project)(this);
}
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:3,代碼來源:combineAll.ts


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