Demo: windowWhen
windowWhen operator emits the incoming data a new observable, as it gets notification from it's specified function observable.
//Emit items in a new observable,
//as it's internal observable notifies
let input = timer(0,1500).pipe(take(7))
.pipe(windowWhen(() =>
interval(500 + Math.random() * 3000)));
//convert the data from the incoming observable into an array
//and emit as the observable completes
let process = mergeMap(v=>v.pipe(toArray()))
let output=input.pipe(process).subscribe(v=>console.log(v))