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 1.9KB

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