I have a simple component with a single button that starts and pauses a stream of numbers generated by RxJS timer.
import { Component, OnInit } from \'@angul
As simple as it can get with one windowToggle
and use active.next(false)
working example: https://stackblitz.com/edit/angular-pdw7kw
defer(() => {
let count = 0;
return stream$.pipe(
windowToggle(on$, () => off$),
exhaustMap(obs => obs),
mergeMap(_ => {
if ((++count) % 5 === 0) {
this.active$.next(false)
return never()
}
return of(count)
}),
)
}).subscribe(console.log)