Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

windowWhen.d.ts 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Observable } from '../Observable';
  2. import { 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. * ```javascript
  22. * const clicks = fromEvent(document, 'click');
  23. * const result = clicks.pipe(
  24. * windowWhen(() => interval(1000 + Math.random() * 4000)),
  25. * map(win => win.pipe(take(2))), // each window has at most 2 emissions
  26. * mergeAll(), // flatten the Observable-of-Observables
  27. * );
  28. * result.subscribe(x => console.log(x));
  29. * ```
  30. *
  31. * @see {@link window}
  32. * @see {@link windowCount}
  33. * @see {@link windowTime}
  34. * @see {@link windowToggle}
  35. * @see {@link bufferWhen}
  36. *
  37. * @param {function(): Observable} closingSelector A function that takes no
  38. * arguments and returns an Observable that signals (on either `next` or
  39. * `complete`) when to close the previous window and start a new one.
  40. * @return {Observable<Observable<T>>} An observable of windows, which in turn
  41. * are Observables.
  42. * @method windowWhen
  43. * @owner Observable
  44. */
  45. export declare function windowWhen<T>(closingSelector: () => Observable<any>): OperatorFunction<T, Observable<T>>;