skip to content

filter

 

filter operator omits all values from source that don't match the predicate function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const { rxObserver } = require('api/v0.3');
const { timer } = require('rxjs');
const { filter, take } = require('rxjs/operators');


const source$ = timer(0, 5).pipe(
    take(4)
  );

const result$ = source$.pipe(
    filter(x => x % 2)
  );

source$.subscribe(rxObserver());
result$.subscribe(rxObserver());

0msstartcomplete00 11 22 33 startcomplete11 33