Front end of the Slack clone application.

windowTime.d.ts 3.5KB

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