source: trip-planner-front/node_modules/rxjs/internal/operators/windowWhen.d.ts@ 188ee53

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

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1import { Observable } from '../Observable';
2import { OperatorFunction } from '../types';
3/**
4 * Branch out the source Observable values as a nested Observable using a
5 * factory function of closing Observables to determine when to start a new
6 * window.
7 *
8 * <span class="informal">It's like {@link bufferWhen}, but emits a nested
9 * Observable instead of an array.</span>
10 *
11 * ![](windowWhen.png)
12 *
13 * Returns an Observable that emits windows of items it collects from the source
14 * Observable. The output Observable emits connected, non-overlapping windows.
15 * It emits the current window and opens a new one whenever the Observable
16 * produced by the specified `closingSelector` function emits an item. The first
17 * window is opened immediately when subscribing to the output Observable.
18 *
19 * ## Example
20 * Emit only the first two clicks events in every window of [1-5] random seconds
21 * ```ts
22 * import { fromEvent, interval } from 'rxjs';
23 * import { windowWhen, map, mergeAll, take } from 'rxjs/operators';
24 *
25 * const clicks = fromEvent(document, 'click');
26 * const result = clicks.pipe(
27 * windowWhen(() => interval(1000 + Math.random() * 4000)),
28 * map(win => win.pipe(take(2))), // each window has at most 2 emissions
29 * mergeAll() // flatten the Observable-of-Observables
30 * );
31 * result.subscribe(x => console.log(x));
32 * ```
33 *
34 * @see {@link window}
35 * @see {@link windowCount}
36 * @see {@link windowTime}
37 * @see {@link windowToggle}
38 * @see {@link bufferWhen}
39 *
40 * @param {function(): Observable} closingSelector A function that takes no
41 * arguments and returns an Observable that signals (on either `next` or
42 * `complete`) when to close the previous window and start a new one.
43 * @return {Observable<Observable<T>>} An observable of windows, which in turn
44 * are Observables.
45 * @method windowWhen
46 * @owner Observable
47 */
48export declare function windowWhen<T>(closingSelector: () => Observable<any>): OperatorFunction<T, Observable<T>>;
Note: See TracBrowser for help on using the repository browser.