a zip code crypto-currency system good for red ONLY

bufferToggle.d.ts 1.9KB

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