UI for Zipcoin Blue

windowToggle.d.ts 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Observable } from '../Observable';
  2. import { OperatorFunction } from '../interfaces';
  3. /**
  4. * Branch out the source Observable values as a nested Observable starting from
  5. * an emission from `openings` and ending when the output of `closingSelector`
  6. * emits.
  7. *
  8. * <span class="informal">It's like {@link bufferToggle}, but emits a nested
  9. * Observable instead of an array.</span>
  10. *
  11. * <img src="./img/windowToggle.png" width="100%">
  12. *
  13. * Returns an Observable that emits windows of items it collects from the source
  14. * Observable. The output Observable emits windows that contain those items
  15. * emitted by the source Observable between the time when the `openings`
  16. * Observable emits an item and when the Observable returned by
  17. * `closingSelector` emits an item.
  18. *
  19. * @example <caption>Every other second, emit the click events from the next 500ms</caption>
  20. * var clicks = Rx.Observable.fromEvent(document, 'click');
  21. * var openings = Rx.Observable.interval(1000);
  22. * var result = clicks.windowToggle(openings, i =>
  23. * i % 2 ? Rx.Observable.interval(500) : Rx.Observable.empty()
  24. * ).mergeAll();
  25. * result.subscribe(x => console.log(x));
  26. *
  27. * @see {@link window}
  28. * @see {@link windowCount}
  29. * @see {@link windowTime}
  30. * @see {@link windowWhen}
  31. * @see {@link bufferToggle}
  32. *
  33. * @param {Observable<O>} openings An observable of notifications to start new
  34. * windows.
  35. * @param {function(value: O): Observable} closingSelector A function that takes
  36. * the value emitted by the `openings` observable and returns an Observable,
  37. * which, when it emits (either `next` or `complete`), signals that the
  38. * associated window should complete.
  39. * @return {Observable<Observable<T>>} An observable of windows, which in turn
  40. * are Observables.
  41. * @method windowToggle
  42. * @owner Observable
  43. */
  44. export declare function windowToggle<T, O>(openings: Observable<O>, closingSelector: (openValue: O) => Observable<any>): OperatorFunction<T, Observable<T>>;