c2751fa8c6306f90630714de04d299d3f7268a149d298569d0aaa7ab21cad6739ee62bcb2387f5abad2a94088dd9f1d6e3a5728e5d03242088d274c0c13776 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Observable } from '../Observable';
  2. import { ObservableInput, OperatorFunction } from '../types';
  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. * ![](windowToggle.png)
  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
  20. *
  21. * Every other second, emit the click events from the next 500ms
  22. *
  23. * ```ts
  24. * import { fromEvent, interval, windowToggle, EMPTY, mergeAll } from 'rxjs';
  25. *
  26. * const clicks = fromEvent(document, 'click');
  27. * const openings = interval(1000);
  28. * const result = clicks.pipe(
  29. * windowToggle(openings, i => i % 2 ? interval(500) : EMPTY),
  30. * mergeAll()
  31. * );
  32. * result.subscribe(x => console.log(x));
  33. * ```
  34. *
  35. * @see {@link window}
  36. * @see {@link windowCount}
  37. * @see {@link windowTime}
  38. * @see {@link windowWhen}
  39. * @see {@link bufferToggle}
  40. *
  41. * @param openings An observable of notifications to start new windows.
  42. * @param closingSelector A function that takes the value emitted by the
  43. * `openings` observable and returns an Observable, which, when it emits a next
  44. * notification, signals that the associated window should complete.
  45. * @return A function that returns an Observable of windows, which in turn are
  46. * Observables.
  47. */
  48. export declare function windowToggle<T, O>(openings: ObservableInput<O>, closingSelector: (openValue: O) => ObservableInput<any>): OperatorFunction<T, Observable<T>>;
  49. //# sourceMappingURL=windowToggle.d.ts.map