1 | import { Observable } from '../Observable';
|
2 | import { ObservableInput, OperatorFunction } from '../types';
|
3 | /**
|
4 | * Branch out the source Observable values as a nested Observable starting from
|
5 | * an emission from `openings` and ending when the output of `closingSelector`
|
6 | * emits.
|
7 | *
|
8 | * <span class="informal">It's like {@link bufferToggle}, but emits a nested
|
9 | * Observable instead of an array.</span>
|
10 | *
|
11 | * 
|
12 | *
|
13 | * Returns an Observable that emits windows of items it collects from the source
|
14 | * Observable. The output Observable emits windows that contain those items
|
15 | * emitted by the source Observable between the time when the `openings`
|
16 | * Observable emits an item and when the Observable returned by
|
17 | * `closingSelector` emits an item.
|
18 | *
|
19 | * ## Example
|
20 | *
|
21 | * Every other second, emit the click events from the next 500ms
|
22 | *
|
23 | * ```ts
|
24 | * import { fromEvent, interval, windowToggle, EMPTY, mergeAll } from 'rxjs';
|
25 | *
|
26 | * const clicks = fromEvent(document, 'click');
|
27 | * const openings = interval(1000);
|
28 | * const result = clicks.pipe(
|
29 | * windowToggle(openings, i => i % 2 ? interval(500) : EMPTY),
|
30 | * mergeAll()
|
31 | * );
|
32 | * result.subscribe(x => console.log(x));
|
33 | * ```
|
34 | *
|
35 | * @see {@link window}
|
36 | * @see {@link windowCount}
|
37 | * @see {@link windowTime}
|
38 | * @see {@link windowWhen}
|
39 | * @see {@link bufferToggle}
|
40 | *
|
41 | * @param {Observable<O>} openings An observable of notifications to start new
|
42 | * windows.
|
43 | * @param {function(value: O): Observable} closingSelector A function that takes
|
44 | * the value emitted by the `openings` observable and returns an Observable,
|
45 | * which, when it emits a next notification, signals that the
|
46 | * associated window should complete.
|
47 | * @return A function that returns an Observable of windows, which in turn are
|
48 | * Observables.
|
49 | */
|
50 | export declare function windowToggle<T, O>(openings: ObservableInput<O>, closingSelector: (openValue: O) => ObservableInput<any>): OperatorFunction<T, Observable<T>>;
|
51 | //# sourceMappingURL=windowToggle.d.ts.map |
\ | No newline at end of file |