1 import { Observable } from '../Observable';
2 import { OperatorFunction, SchedulerLike } from '../types';
4 * Branch out the source Observable values as a nested Observable periodically
7 * <span class="informal">It's like {@link bufferTime}, but emits a nested
8 * Observable instead of an array.</span>
12 * Returns an Observable that emits windows of items it collects from the source
13 * Observable. The output Observable starts a new window periodically, as
14 * determined by the `windowCreationInterval` argument. It emits each window
15 * after a fixed timespan, specified by the `windowTimeSpan` argument. When the
16 * source Observable completes or encounters an error, the output Observable
17 * emits the current window and propagates the notification from the source
18 * Observable. If `windowCreationInterval` is not provided, the output
19 * Observable starts a new window when the previous window of duration
20 * `windowTimeSpan` completes. If `maxWindowCount` is provided, each window
21 * will emit at most fixed number of values. Window will complete immediately
22 * after emitting last value and next one still will open as specified by
23 * `windowTimeSpan` and `windowCreationInterval` arguments.
26 * In every window of 1 second each, emit at most 2 click events
28 * import { fromEvent } from 'rxjs';
29 * import { windowTime, map, mergeAll, take } from 'rxjs/operators';
31 * const clicks = fromEvent(document, 'click');
32 * const result = clicks.pipe(
34 * map(win => win.pipe(take(2))), // each window has at most 2 emissions
35 * mergeAll(), // flatten the Observable-of-Observables
37 * result.subscribe(x => console.log(x));
40 * Every 5 seconds start a window 1 second long, and emit at most 2 click events per window
42 * import { fromEvent } from 'rxjs';
43 * import { windowTime, map, mergeAll, take } from 'rxjs/operators';
45 * const clicks = fromEvent(document, 'click');
46 * const result = clicks.pipe(
47 * windowTime(1000, 5000),
48 * map(win => win.pipe(take(2))), // each window has at most 2 emissions
49 * mergeAll(), // flatten the Observable-of-Observables
51 * result.subscribe(x => console.log(x));
54 * Same as example above but with maxWindowCount instead of take
56 * import { fromEvent } from 'rxjs';
57 * import { windowTime, mergeAll } from 'rxjs/operators';
59 * const clicks = fromEvent(document, 'click');
60 * const result = clicks.pipe(
61 * windowTime(1000, 5000, 2), // each window has still at most 2 emissions
62 * mergeAll(), // flatten the Observable-of-Observables
64 * result.subscribe(x => console.log(x));
68 * @see {@link windowCount}
69 * @see {@link windowToggle}
70 * @see {@link windowWhen}
71 * @see {@link bufferTime}
73 * @param {number} windowTimeSpan The amount of time to fill each window.
74 * @param {number} [windowCreationInterval] The interval at which to start new
76 * @param {number} [maxWindowSize=Number.POSITIVE_INFINITY] Max number of
77 * values each window can emit before completion.
78 * @param {SchedulerLike} [scheduler=async] The scheduler on which to schedule the
79 * intervals that determine window boundaries.
80 * @return {Observable<Observable<T>>} An observable of windows, which in turn
85 export declare function windowTime<T>(windowTimeSpan: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
86 export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
87 export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, maxWindowSize: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;