source: trip-planner-front/node_modules/rxjs/internal/operators/bufferWhen.d.ts@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import { Observable } from '../Observable';
2import { OperatorFunction } from '../types';
3/**
4 * Buffers the source Observable values, using a factory function of closing
5 * Observables to determine when to close, emit, and reset the buffer.
6 *
7 * <span class="informal">Collects values from the past as an array. When it
8 * starts collecting values, it calls a function that returns an Observable that
9 * tells when to close the buffer and restart collecting.</span>
10 *
11 * ![](bufferWhen.png)
12 *
13 * Opens a buffer immediately, then closes the buffer when the observable
14 * returned by calling `closingSelector` function emits a value. When it closes
15 * the buffer, it immediately opens a new buffer and repeats the process.
16 *
17 * ## Example
18 *
19 * Emit an array of the last clicks every [1-5] random seconds
20 *
21 * ```ts
22 * import { fromEvent, interval } from 'rxjs';
23 * import { bufferWhen } from 'rxjs/operators';
24 *
25 * const clicks = fromEvent(document, 'click');
26 * const buffered = clicks.pipe(bufferWhen(() =>
27 * interval(1000 + Math.random() * 4000)
28 * ));
29 * buffered.subscribe(x => console.log(x));
30 * ```
31 *
32 *
33 * @see {@link buffer}
34 * @see {@link bufferCount}
35 * @see {@link bufferTime}
36 * @see {@link bufferToggle}
37 * @see {@link windowWhen}
38 *
39 * @param {function(): Observable} closingSelector A function that takes no
40 * arguments and returns an Observable that signals buffer closure.
41 * @return {Observable<T[]>} An observable of arrays of buffered values.
42 * @method bufferWhen
43 * @owner Observable
44 */
45export declare function bufferWhen<T>(closingSelector: () => Observable<any>): OperatorFunction<T, T[]>;
Note: See TracBrowser for help on using the repository browser.