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.

windowTime.d.ts 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction, SchedulerLike } from '../types';
  3. /**
  4. * Branch out the source Observable values as a nested Observable periodically
  5. * in time.
  6. *
  7. * <span class="informal">It's like {@link bufferTime}, but emits a nested
  8. * Observable instead of an array.</span>
  9. *
  10. * ![](windowTime.png)
  11. *
  12. * Returns an Observable that emits windows of items it collects from the source
  13. * Observable. The output Observable starts a new window periodically, as
  14. * determined by the `windowCreationInterval` argument. It emits each window
  15. * after a fixed timespan, specified by the `windowTimeSpan` argument. When the
  16. * source Observable completes or encounters an error, the output Observable
  17. * emits the current window and propagates the notification from the source
  18. * Observable. If `windowCreationInterval` is not provided, the output
  19. * Observable starts a new window when the previous window of duration
  20. * `windowTimeSpan` completes. If `maxWindowCount` is provided, each window
  21. * will emit at most fixed number of values. Window will complete immediately
  22. * after emitting last value and next one still will open as specified by
  23. * `windowTimeSpan` and `windowCreationInterval` arguments.
  24. *
  25. * ## Examples
  26. * In every window of 1 second each, emit at most 2 click events
  27. * ```javascript
  28. * const clicks = fromEvent(document, 'click');
  29. * const result = clicks.pipe(
  30. * windowTime(1000),
  31. * map(win => win.take(2)), // each window has at most 2 emissions
  32. * mergeAll(), // flatten the Observable-of-Observables
  33. * );
  34. * result.subscribe(x => console.log(x));
  35. * ```
  36. *
  37. * Every 5 seconds start a window 1 second long, and emit at most 2 click events per window
  38. * ```javascript
  39. * const clicks = fromEvent(document, 'click');
  40. * const result = clicks.pipe(
  41. * windowTime(1000, 5000),
  42. * map(win => win.take(2)), // each window has at most 2 emissions
  43. * mergeAll(), // flatten the Observable-of-Observables
  44. * );
  45. * result.subscribe(x => console.log(x));
  46. * ```
  47. *
  48. * Same as example above but with maxWindowCount instead of take
  49. * ```javascript
  50. * const clicks = fromEvent(document, 'click');
  51. * const result = clicks.pipe(
  52. * windowTime(1000, 5000, 2), // each window has still at most 2 emissions
  53. * mergeAll(), // flatten the Observable-of-Observables
  54. * );
  55. * result.subscribe(x => console.log(x));
  56. * ```
  57. *
  58. * @see {@link window}
  59. * @see {@link windowCount}
  60. * @see {@link windowToggle}
  61. * @see {@link windowWhen}
  62. * @see {@link bufferTime}
  63. *
  64. * @param {number} windowTimeSpan The amount of time to fill each window.
  65. * @param {number} [windowCreationInterval] The interval at which to start new
  66. * windows.
  67. * @param {number} [maxWindowSize=Number.POSITIVE_INFINITY] Max number of
  68. * values each window can emit before completion.
  69. * @param {SchedulerLike} [scheduler=async] The scheduler on which to schedule the
  70. * intervals that determine window boundaries.
  71. * @return {Observable<Observable<T>>} An observable of windows, which in turn
  72. * are Observables.
  73. * @method windowTime
  74. * @owner Observable
  75. */
  76. export declare function windowTime<T>(windowTimeSpan: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
  77. export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;
  78. export declare function windowTime<T>(windowTimeSpan: number, windowCreationInterval: number, maxWindowSize: number, scheduler?: SchedulerLike): OperatorFunction<T, Observable<T>>;