12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. var window_1 = require('../operators/window');
  3. /**
  4. * Branch out the source Observable values as a nested Observable whenever
  5. * `windowBoundaries` emits.
  6. *
  7. * <span class="informal">It's like {@link buffer}, but emits a nested Observable
  8. * instead of an array.</span>
  9. *
  10. * <img src="./img/window.png" width="100%">
  11. *
  12. * Returns an Observable that emits windows of items it collects from the source
  13. * Observable. The output Observable emits connected, non-overlapping
  14. * windows. It emits the current window and opens a new one whenever the
  15. * Observable `windowBoundaries` emits an item. Because each window is an
  16. * Observable, the output is a higher-order Observable.
  17. *
  18. * @example <caption>In every window of 1 second each, emit at most 2 click events</caption>
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var interval = Rx.Observable.interval(1000);
  21. * var result = clicks.window(interval)
  22. * .map(win => win.take(2)) // each window has at most 2 emissions
  23. * .mergeAll(); // flatten the Observable-of-Observables
  24. * result.subscribe(x => console.log(x));
  25. *
  26. * @see {@link windowCount}
  27. * @see {@link windowTime}
  28. * @see {@link windowToggle}
  29. * @see {@link windowWhen}
  30. * @see {@link buffer}
  31. *
  32. * @param {Observable<any>} windowBoundaries An Observable that completes the
  33. * previous window and starts a new window.
  34. * @return {Observable<Observable<T>>} An Observable of windows, which are
  35. * Observables emitting values of the source Observable.
  36. * @method window
  37. * @owner Observable
  38. */
  39. function window(windowBoundaries) {
  40. return window_1.window(windowBoundaries)(this);
  41. }
  42. exports.window = window;
  43. //# sourceMappingURL=window.js.map