614913968c717185a7974550823e8919b8dbcaa013e26d6c4d7163ec5abf4ec7c5f69100ea6effd136fefd8901d83b6f1c077080e185ba74bb8901321ec593 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction } from '../types';
  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. * ![](windowCount.png)
  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. * ## Examples
  22. *
  23. * Ignore every 3rd click event, starting from the first one
  24. *
  25. * ```ts
  26. * import { fromEvent, windowCount, map, skip, mergeAll } from 'rxjs';
  27. *
  28. * const clicks = fromEvent(document, 'click');
  29. * const result = clicks.pipe(
  30. * windowCount(3),
  31. * map(win => win.pipe(skip(1))), // skip first of every 3 clicks
  32. * mergeAll() // flatten the Observable-of-Observables
  33. * );
  34. * result.subscribe(x => console.log(x));
  35. * ```
  36. *
  37. * Ignore every 3rd click event, starting from the third one
  38. *
  39. * ```ts
  40. * import { fromEvent, windowCount, mergeAll } from 'rxjs';
  41. *
  42. * const clicks = fromEvent(document, 'click');
  43. * const result = clicks.pipe(
  44. * windowCount(2, 3),
  45. * mergeAll() // flatten the Observable-of-Observables
  46. * );
  47. * result.subscribe(x => console.log(x));
  48. * ```
  49. *
  50. * @see {@link window}
  51. * @see {@link windowTime}
  52. * @see {@link windowToggle}
  53. * @see {@link windowWhen}
  54. * @see {@link bufferCount}
  55. *
  56. * @param windowSize The maximum number of values emitted by each window.
  57. * @param startWindowEvery Interval at which to start a new window. For example
  58. * if `startWindowEvery` is `2`, then a new window will be started on every
  59. * other value from the source. A new window is started at the beginning of the
  60. * source by default.
  61. * @return A function that returns an Observable of windows, which in turn are
  62. * Observable of values.
  63. */
  64. export declare function windowCount<T>(windowSize: number, startWindowEvery?: number): OperatorFunction<T, Observable<T>>;
  65. //# sourceMappingURL=windowCount.d.ts.map