Front end of the Slack clone application.

windowCount.d.ts 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction } from '../interfaces';
  3. /**
  4. * Branch out the source Observable values as a nested Observable with each
  5. * nested Observable emitting at most `windowSize` values.
  6. *
  7. * <span class="informal">It's like {@link bufferCount}, but emits a nested
  8. * Observable instead of an array.</span>
  9. *
  10. * <img src="./img/windowCount.png" width="100%">
  11. *
  12. * Returns an Observable that emits windows of items it collects from the source
  13. * Observable. The output Observable emits windows every `startWindowEvery`
  14. * items, each containing no more than `windowSize` items. When the source
  15. * Observable completes or encounters an error, the output Observable emits
  16. * the current window and propagates the notification from the source
  17. * Observable. If `startWindowEvery` is not provided, then new windows are
  18. * started immediately at the start of the source and when each window completes
  19. * with size `windowSize`.
  20. *
  21. * @example <caption>Ignore every 3rd click event, starting from the first one</caption>
  22. * var clicks = Rx.Observable.fromEvent(document, 'click');
  23. * var result = clicks.windowCount(3)
  24. * .map(win => win.skip(1)) // skip first of every 3 clicks
  25. * .mergeAll(); // flatten the Observable-of-Observables
  26. * result.subscribe(x => console.log(x));
  27. *
  28. * @example <caption>Ignore every 3rd click event, starting from the third one</caption>
  29. * var clicks = Rx.Observable.fromEvent(document, 'click');
  30. * var result = clicks.windowCount(2, 3)
  31. * .mergeAll(); // flatten the Observable-of-Observables
  32. * result.subscribe(x => console.log(x));
  33. *
  34. * @see {@link window}
  35. * @see {@link windowTime}
  36. * @see {@link windowToggle}
  37. * @see {@link windowWhen}
  38. * @see {@link bufferCount}
  39. *
  40. * @param {number} windowSize The maximum number of values emitted by each
  41. * window.
  42. * @param {number} [startWindowEvery] Interval at which to start a new window.
  43. * For example if `startWindowEvery` is `2`, then a new window will be started
  44. * on every other value from the source. A new window is started at the
  45. * beginning of the source by default.
  46. * @return {Observable<Observable<T>>} An Observable of windows, which in turn
  47. * are Observable of values.
  48. * @method windowCount
  49. * @owner Observable
  50. */
  51. export declare function windowCount<T>(windowSize: number, startWindowEvery?: number): OperatorFunction<T, Observable<T>>;