windowTime
operator creates a new branch of observable from the source observable by indicated time
windowTime(windowTimeSpan: number, windowCreationInterval?: number, maxWindowSize?: number)
windowTimeSpan
indicate the time of each window (branch of observable).
windowCreatingInterval?
: indicate the interval time to create the new branch of observable.
maxWindowSize
: indicate the maximum number of emissions for each new branch of observables.
windowTimeSpan
if only pass windowTimeSpan
parameter, it will create a new branch of observable when previous is finished
import { interval } from 'rxjs';
import { windowTime, take } from 'rxjs/operators';
const source$ = interval(1500).pipe(take(7));
const result$ = source$.pipe(windowTime(5000));
windowTimeSpan
and windowCreatingInterval
import { interval } from 'rxjs';
import { windowTime, take } from 'rxjs/operators';
const source$ = interval(1500).pipe(take(7));
const result$ = source$.pipe(windowTime(5000, 3000));
maxWindowSize
import { interval } from 'rxjs';
import { windowTime, take } from 'rxjs/operators';
const source$ = interval(1000).pipe(take(7));
const result$ = source$.pipe(windowTime(5000, 3000, 2));
Official Doc: rxjs.windowTime