UNPKG

1.45 kBTypeScriptView Raw
1import { OperatorFunction, ObservableInput } from '../types';
2/**
3 * Buffers the source Observable values until `closingNotifier` emits.
4 *
5 * <span class="informal">Collects values from the past as an array, and emits
6 * that array only when another Observable emits.</span>
7 *
8 * ![](buffer.png)
9 *
10 * Buffers the incoming Observable values until the given `closingNotifier`
11 * `ObservableInput` (that internally gets converted to an Observable)
12 * emits a value, at which point it emits the buffer on the output
13 * Observable and starts a new buffer internally, awaiting the next time
14 * `closingNotifier` emits.
15 *
16 * ## Example
17 *
18 * On every click, emit array of most recent interval events
19 *
20 * ```ts
21 * import { fromEvent, interval, buffer } from 'rxjs';
22 *
23 * const clicks = fromEvent(document, 'click');
24 * const intervalEvents = interval(1000);
25 * const buffered = intervalEvents.pipe(buffer(clicks));
26 * buffered.subscribe(x => console.log(x));
27 * ```
28 *
29 * @see {@link bufferCount}
30 * @see {@link bufferTime}
31 * @see {@link bufferToggle}
32 * @see {@link bufferWhen}
33 * @see {@link window}
34 *
35 * @param closingNotifier An `ObservableInput` that signals the
36 * buffer to be emitted on the output Observable.
37 * @return A function that returns an Observable of buffers, which are arrays
38 * of values.
39 */
40export declare function buffer<T>(closingNotifier: ObservableInput<any>): OperatorFunction<T, T[]>;
41//# sourceMappingURL=buffer.d.ts.map
\No newline at end of file