skip to content

find

 

find operator takes in predicate function and returns an Observable that will emit first value from source that matches predicate and will immediately complete:

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 { find, take } = require('rxjs/operators');


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

const result$ = source$.pipe(
    find(x => x > 1)
  );

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

0msstartcomplete00 11 22 33 startcomplete22