import { fromEvent, delayWhen, interval, of, Subject } from 'rxjs'; const sourceSebjec = new Subject<boolean>(); const sourceAction$ = sourceSebjec.asObservable(); fromEvent(document, 'click').subscribe({ next: (x) => { console.log('CLik next: .. iniciou souce', x); sourceSebjec.next(false); }, error: (x) => console.log('Clik erro:', x), complete: () => console.log('Clik complete'), }); sourceAction$.pipe(delayWhen((v) => (v ? interval(2000) : of(0)))).subscribe({ next: (x) => { console.log('Souce next:', x); }, error: (x) => console.log('Souce erro:', x), complete: () => console.log('Souce complete'), });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter