Contents

concatAll operator in RxJs

Updated on 2021-02-09

concatAll Operator

Can be imported from here:

1
2
3
import { concatAll } from 'rxjs/operators';
// or
const { concatAll } = require('rxjs/operators');

For official documentation, visit https://rxjs-dev.firebaseapp.com/api/operators/concatAll

Concatenates higher order observables into first order observable in order.

Note: concatAll() is equivalent to mergeAll() with concurrency parameter equal to 1.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import { fromEvent, interval } from 'rxjs';
import { map, take, concatAll } from 'rxjs/operators';
 
const clicks = fromEvent(document, 'click');
const triggerIntervalObservable$ = interval(500).pipe(take(4));
const higherOrder = clicks.pipe(
  map(ev => triggerIntervalObservable$),
);
const firstOrder = higherOrder.pipe(concatAll());
firstOrder.subscribe(x => console.log(x));
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# click
0
1
2
3
# click
0
1
2
3

Комментарии