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.

bufferToggle.d.ts 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { OperatorFunction, SubscribableOrPromise } from '../types';
  2. /**
  3. * Buffers the source Observable values starting from an emission from
  4. * `openings` and ending when the output of `closingSelector` emits.
  5. *
  6. * <span class="informal">Collects values from the past as an array. Starts
  7. * collecting only when `opening` emits, and calls the `closingSelector`
  8. * function to get an Observable that tells when to close the buffer.</span>
  9. *
  10. * ![](bufferToggle.png)
  11. *
  12. * Buffers values from the source by opening the buffer via signals from an
  13. * Observable provided to `openings`, and closing and sending the buffers when
  14. * a Subscribable or Promise returned by the `closingSelector` function emits.
  15. *
  16. * ## Example
  17. *
  18. * Every other second, emit the click events from the next 500ms
  19. *
  20. * ```javascript
  21. * const clicks = fromEvent(document, 'click');
  22. * const openings = interval(1000);
  23. * const buffered = clicks.pipe(bufferToggle(openings, i =>
  24. * i % 2 ? interval(500) : empty()
  25. * ));
  26. * buffered.subscribe(x => console.log(x));
  27. * ```
  28. *
  29. * @see {@link buffer}
  30. * @see {@link bufferCount}
  31. * @see {@link bufferTime}
  32. * @see {@link bufferWhen}
  33. * @see {@link windowToggle}
  34. *
  35. * @param {SubscribableOrPromise<O>} openings A Subscribable or Promise of notifications to start new
  36. * buffers.
  37. * @param {function(value: O): SubscribableOrPromise} closingSelector A function that takes
  38. * the value emitted by the `openings` observable and returns a Subscribable or Promise,
  39. * which, when it emits, signals that the associated buffer should be emitted
  40. * and cleared.
  41. * @return {Observable<T[]>} An observable of arrays of buffered values.
  42. * @method bufferToggle
  43. * @owner Observable
  44. */
  45. export declare function bufferToggle<T, O>(openings: SubscribableOrPromise<O>, closingSelector: (value: O) => SubscribableOrPromise<any>): OperatorFunction<T, T[]>;