windowWhen
Operator you can pass an observable to indicate
when close current branch of observable and start the new one.
windowWhen(closingSelector: () => Observable): Observable
click the page to generate a new branch of observable
import { fromEvent, interval } from 'rxjs';
import { windowWhen, map, mergeAll, take } from 'rxjs/operators';
const source$ = interval(1500);
const close$ = fromEvent(document, 'click');
const result$ = source$.pipe(
windowWhen(() => close$),
);
Official Doc: rxjs.windowWhen