c83758b85a9738df446b0a7a2b63622db8fcdb58c76afac44b641a5791a10904c19d8524535ddb28136f8a58943e5ae60beee9aef4932203498e1a3979762a 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { OperatorFunction, ObservableInput } from '../types';
  2. /**
  3. * Buffers the source Observable values until `closingNotifier` emits.
  4. *
  5. * <span class="informal">Collects values from the past as an array, and emits
  6. * that array only when another Observable emits.</span>
  7. *
  8. * ![](buffer.png)
  9. *
  10. * Buffers the incoming Observable values until the given `closingNotifier`
  11. * `ObservableInput` (that internally gets converted to an Observable)
  12. * emits a value, at which point it emits the buffer on the output
  13. * Observable and starts a new buffer internally, awaiting the next time
  14. * `closingNotifier` emits.
  15. *
  16. * ## Example
  17. *
  18. * On every click, emit array of most recent interval events
  19. *
  20. * ```ts
  21. * import { fromEvent, interval, buffer } from 'rxjs';
  22. *
  23. * const clicks = fromEvent(document, 'click');
  24. * const intervalEvents = interval(1000);
  25. * const buffered = intervalEvents.pipe(buffer(clicks));
  26. * buffered.subscribe(x => console.log(x));
  27. * ```
  28. *
  29. * @see {@link bufferCount}
  30. * @see {@link bufferTime}
  31. * @see {@link bufferToggle}
  32. * @see {@link bufferWhen}
  33. * @see {@link window}
  34. *
  35. * @param closingNotifier An `ObservableInput` that signals the
  36. * buffer to be emitted on the output Observable.
  37. * @return A function that returns an Observable of buffers, which are arrays
  38. * of values.
  39. */
  40. export declare function buffer<T>(closingNotifier: ObservableInput<any>): OperatorFunction<T, T[]>;
  41. //# sourceMappingURL=buffer.d.ts.map