take
operator emits indicated count of values from source observable.
take
operatorimport { interval } from 'rxjs';
import { take } from 'rxjs/operators';
const source$ = interval(1000);
const result$ = source$.pipe(take(5));
take
operator with click eventimport { fromEvent } from 'rxjs';
import { take } from 'rxjs/operators';
const source$ = fromEvent(document, 'click');
const result$ = source$.pipe(take(5));
Official Doc: rxjs.take