Demo:  windowToggle

windowToggle works similar to the bufferToggle except that the first one emits the chunks of items using observables whereas the later one emits them using arrays.

windowToggle(openingObservable, (v) => dependentClosingObservable)
//Emit incoming items in a new observable every 4 sec,
//which closes by the closing observable in next 3 seconds
let input = timer(500,1000).pipe( take(12),
               windowToggle(timer(0, 4000),
                           ()=>timer(3000)));

//convert the data from the incoming observables into arrays
let process = mergeMap(v=>v.pipe(toArray()))

let output = input.pipe(process).subscribe(v=>console.log(v))