12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { Observable } from '../Observable';
- import { ObservableInput, OperatorFunction } from '../types';
- /**
- * Branch out the source Observable values as a nested Observable using a
- * factory function of closing Observables to determine when to start a new
- * window.
- *
- * <span class="informal">It's like {@link bufferWhen}, but emits a nested
- * Observable instead of an array.</span>
- *
- * 
- *
- * Returns an Observable that emits windows of items it collects from the source
- * Observable. The output Observable emits connected, non-overlapping windows.
- * It emits the current window and opens a new one whenever the Observable
- * produced by the specified `closingSelector` function emits an item. The first
- * window is opened immediately when subscribing to the output Observable.
- *
- * ## Example
- *
- * Emit only the first two clicks events in every window of [1-5] random seconds
- *
- * ```ts
- * import { fromEvent, windowWhen, interval, map, take, mergeAll } from 'rxjs';
- *
- * const clicks = fromEvent(document, 'click');
- * const result = clicks.pipe(
- * windowWhen(() => interval(1000 + Math.random() * 4000)),
- * map(win => win.pipe(take(2))), // take at most 2 emissions from each window
- * mergeAll() // flatten the Observable-of-Observables
- * );
- * result.subscribe(x => console.log(x));
- * ```
- *
- * @see {@link window}
- * @see {@link windowCount}
- * @see {@link windowTime}
- * @see {@link windowToggle}
- * @see {@link bufferWhen}
- *
- * @param closingSelector A function that takes no arguments and returns an
- * {@link ObservableInput} (that gets converted to Observable) that signals
- * (on either `next` or `complete`) when to close the previous window and
- * start a new one.
- * @return A function that returns an Observable of windows, which in turn are
- * Observables.
- */
- export declare function windowWhen<T>(closingSelector: () => ObservableInput<any>): OperatorFunction<T, Observable<T>>;
- //# sourceMappingURL=windowWhen.d.ts.map
|