first
Operator emits only the first value.
you also can pass personalized compare function: see this example
import { interval } from 'rxjs';
import { first, take } from 'rxjs/operators';
const source$ = interval(1500).pipe(take(4));
const result$ = source$.pipe(first());
return the first 2
value
import { interval } from 'rxjs';
import { first, take } from 'rxjs/operators';
const source$ = interval(1500).pipe(take(4));
const result$ = source$.pipe(first((i) => i === 2));
Official Doc: rxjs.first