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.

windowToggle.d.ts 2.0KB

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