UNPKG

1.86 kBTypeScriptView Raw
1import { Observable } from '../Observable';
2import { OperatorFunction, ObservableInput } from '../types';
3/**
4 * Branch out the source Observable values as a nested Observable whenever
5 * `windowBoundaries` emits.
6 *
7 * <span class="informal">It's like {@link buffer}, but emits a nested Observable
8 * instead of an array.</span>
9 *
10 * ![](window.png)
11 *
12 * Returns an Observable that emits windows of items it collects from the source
13 * Observable. The output Observable emits connected, non-overlapping
14 * windows. It emits the current window and opens a new one whenever the
15 * `windowBoundaries` emits an item. `windowBoundaries` can be any type that
16 * `ObservableInput` accepts. It internally gets converted to an Observable.
17 * Because each window is an Observable, the output is a higher-order Observable.
18 *
19 * ## Example
20 *
21 * In every window of 1 second each, emit at most 2 click events
22 *
23 * ```ts
24 * import { fromEvent, interval, window, map, take, mergeAll } from 'rxjs';
25 *
26 * const clicks = fromEvent(document, 'click');
27 * const sec = interval(1000);
28 * const result = clicks.pipe(
29 * window(sec),
30 * map(win => win.pipe(take(2))), // take at most 2 emissions from each window
31 * mergeAll() // flatten the Observable-of-Observables
32 * );
33 * result.subscribe(x => console.log(x));
34 * ```
35 *
36 * @see {@link windowCount}
37 * @see {@link windowTime}
38 * @see {@link windowToggle}
39 * @see {@link windowWhen}
40 * @see {@link buffer}
41 *
42 * @param windowBoundaries An `ObservableInput` that completes the
43 * previous window and starts a new window.
44 * @return A function that returns an Observable of windows, which are
45 * Observables emitting values of the source Observable.
46 */
47export declare function window<T>(windowBoundaries: ObservableInput<any>): OperatorFunction<T, Observable<T>>;
48//# sourceMappingURL=window.d.ts.map
\No newline at end of file