Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bufferWhen.d.ts 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction } from '../types';
  3. /**
  4. * Buffers the source Observable values, using a factory function of closing
  5. * Observables to determine when to close, emit, and reset the buffer.
  6. *
  7. * <span class="informal">Collects values from the past as an array. When it
  8. * starts collecting values, it calls a function that returns an Observable that
  9. * tells when to close the buffer and restart collecting.</span>
  10. *
  11. * ![](bufferWhen.png)
  12. *
  13. * Opens a buffer immediately, then closes the buffer when the observable
  14. * returned by calling `closingSelector` function emits a value. When it closes
  15. * the buffer, it immediately opens a new buffer and repeats the process.
  16. *
  17. * ## Example
  18. *
  19. * Emit an array of the last clicks every [1-5] random seconds
  20. *
  21. * ```javascript
  22. * const clicks = fromEvent(document, 'click');
  23. * const buffered = clicks.pipe(bufferWhen(() =>
  24. * interval(1000 + Math.random() * 4000)
  25. * ));
  26. * buffered.subscribe(x => console.log(x));
  27. * ```
  28. *
  29. *
  30. * @see {@link buffer}
  31. * @see {@link bufferCount}
  32. * @see {@link bufferTime}
  33. * @see {@link bufferToggle}
  34. * @see {@link windowWhen}
  35. *
  36. * @param {function(): Observable} closingSelector A function that takes no
  37. * arguments and returns an Observable that signals buffer closure.
  38. * @return {Observable<T[]>} An observable of arrays of buffered values.
  39. * @method bufferWhen
  40. * @owner Observable
  41. */
  42. export declare function bufferWhen<T>(closingSelector: () => Observable<any>): OperatorFunction<T, T[]>;