rxjs_pipe.js 257 B

123456789101112
  1. import { range } from 'rxjs/observable/range';
  2. import { map, filter, scan } from 'rxjs/operators';
  3. const source$ = range(0, 10);
  4. source$.pipe(
  5. filter(x => x % 2 === 0),
  6. map(x => x + x),
  7. scan((acc, x) => acc + x, 0)
  8. )
  9. .subscribe(x => console.log(x))