UI for Zipcoin Blue

windowTime.d.ts 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { IScheduler } from '../Scheduler';
  2. import { Observable } from '../Observable';
  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. * <img src="./img/windowTime.png" width="100%">
  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. * @example <caption>In every window of 1 second each, emit at most 2 click events</caption>
  26. * var clicks = Rx.Observable.fromEvent(document, 'click');
  27. * var result = clicks.windowTime(1000)
  28. * .map(win => win.take(2)) // each window has at most 2 emissions
  29. * .mergeAll(); // flatten the Observable-of-Observables
  30. * result.subscribe(x => console.log(x));
  31. *
  32. * @example <caption>Every 5 seconds start a window 1 second long, and emit at most 2 click events per window</caption>
  33. * var clicks = Rx.Observable.fromEvent(document, 'click');
  34. * var result = clicks.windowTime(1000, 5000)
  35. * .map(win => win.take(2)) // each window has at most 2 emissions
  36. * .mergeAll(); // flatten the Observable-of-Observables
  37. * result.subscribe(x => console.log(x));
  38. *
  39. * @example <caption>Same as example above but with maxWindowCount instead of take</caption>
  40. * var clicks = Rx.Observable.fromEvent(document, 'click');
  41. * var result = clicks.windowTime(1000, 5000, 2) // each window has still at most 2 emissions
  42. * .mergeAll(); // flatten the Observable-of-Observables
  43. * result.subscribe(x => console.log(x));
  44. * @see {@link window}
  45. * @see {@link windowCount}
  46. * @see {@link windowToggle}
  47. * @see {@link windowWhen}
  48. * @see {@link bufferTime}
  49. *
  50. * @param {number} windowTimeSpan The amount of time to fill each window.
  51. * @param {number} [windowCreationInterval] The interval at which to start new
  52. * windows.
  53. * @param {number} [maxWindowSize=Number.POSITIVE_INFINITY] Max number of
  54. * values each window can emit before completion.
  55. * @param {Scheduler} [scheduler=async] The scheduler on which to schedule the
  56. * intervals that determine window boundaries.
  57. * @return {Observable<Observable<T>>} An observable of windows, which in turn
  58. * are Observables.
  59. * @method windowTime
  60. * @owner Observable
  61. */
  62. export declare function windowTime<T>(this: Observable<T>, windowTimeSpan: number, scheduler?: IScheduler): Observable<Observable<T>>;
  63. export declare function windowTime<T>(this: Observable<T>, windowTimeSpan: number, windowCreationInterval: number, scheduler?: IScheduler): Observable<Observable<T>>;
  64. export declare function windowTime<T>(this: Observable<T>, windowTimeSpan: number, windowCreationInterval: number, maxWindowSize: number, scheduler?: IScheduler): Observable<Observable<T>>;