windowWhen
연산자(operator) 정의: windowWhen(closingSelector: function(): Observable): Observable
Close window at provided time frame emitting observable of collected values from source.
Examples
Example 1: Open and close window at interval
//emit immediately then every 1s
const source = Rx.Observable.timer(0,1000);
const example = source
//close window every 5s and emit observable of collected values from source
.windowWhen((val) => Rx.Observable.interval(5000))
.do(() => console.log('NEW WINDOW!'))
const subscribeTwo = example
//window emits nested observable
.mergeAll()
/*
output:
"NEW WINDOW!"
0
1
2
3
4
"NEW WINDOW!"
5
6
7
8
9
*/
.subscribe(val => console.log(val));
Additional Resources
- windowWhen - Official docs
Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/operator/windowWhen.ts