Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

buffer.d.ts 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction } from '../types';
  3. /**
  4. * Buffers the source Observable values until `closingNotifier` emits.
  5. *
  6. * <span class="informal">Collects values from the past as an array, and emits
  7. * that array only when another Observable emits.</span>
  8. *
  9. * ![](buffer.png)
  10. *
  11. * Buffers the incoming Observable values until the given `closingNotifier`
  12. * Observable 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 } from 'rxjs';
  22. * import { buffer } from 'rxjs/operators';
  23. *
  24. * const clicks = fromEvent(document, 'click');
  25. * const intervalEvents = interval(1000);
  26. * const buffered = intervalEvents.pipe(buffer(clicks));
  27. * buffered.subscribe(x => console.log(x));
  28. * ```
  29. *
  30. * @see {@link bufferCount}
  31. * @see {@link bufferTime}
  32. * @see {@link bufferToggle}
  33. * @see {@link bufferWhen}
  34. * @see {@link window}
  35. *
  36. * @param {Observable<any>} closingNotifier An Observable that signals the
  37. * buffer to be emitted on the output Observable.
  38. * @return {Observable<T[]>} An Observable of buffers, which are arrays of
  39. * values.
  40. * @method buffer
  41. * @owner Observable
  42. */
  43. export declare function buffer<T>(closingNotifier: Observable<any>): OperatorFunction<T, T[]>;