b501b08490dff0edf3dfd427e68e4787efd8d615c4662859e28bcf099e798225caca55e84eea5f2ba5b90c34b5f37666acd882627f32e8e5c9351ace426fcd 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { OperatorFunction, ObservableInput, ObservedValueOf } from '../types';
  2. /**
  3. * Converts a higher-order Observable into a first-order Observable
  4. * producing values only from the most recent observable sequence
  5. *
  6. * <span class="informal">Flattens an Observable-of-Observables.</span>
  7. *
  8. * ![](switchAll.png)
  9. *
  10. * `switchAll` subscribes to a source that is an observable of observables, also known as a
  11. * "higher-order observable" (or `Observable<Observable<T>>`). It subscribes to the most recently
  12. * provided "inner observable" emitted by the source, unsubscribing from any previously subscribed
  13. * to inner observable, such that only the most recent inner observable may be subscribed to at
  14. * any point in time. The resulting observable returned by `switchAll` will only complete if the
  15. * source observable completes, *and* any currently subscribed to inner observable also has completed,
  16. * if there are any.
  17. *
  18. * ## Examples
  19. *
  20. * Spawn a new interval observable for each click event, but for every new
  21. * click, cancel the previous interval and subscribe to the new one
  22. *
  23. * ```ts
  24. * import { fromEvent, tap, map, interval, switchAll } from 'rxjs';
  25. *
  26. * const clicks = fromEvent(document, 'click').pipe(tap(() => console.log('click')));
  27. * const source = clicks.pipe(map(() => interval(1000)));
  28. *
  29. * source
  30. * .pipe(switchAll())
  31. * .subscribe(x => console.log(x));
  32. *
  33. * // Output
  34. * // click
  35. * // 0
  36. * // 1
  37. * // 2
  38. * // 3
  39. * // ...
  40. * // click
  41. * // 0
  42. * // 1
  43. * // 2
  44. * // ...
  45. * // click
  46. * // ...
  47. * ```
  48. *
  49. * @see {@link combineLatestAll}
  50. * @see {@link concatAll}
  51. * @see {@link exhaustAll}
  52. * @see {@link switchMap}
  53. * @see {@link switchMapTo}
  54. * @see {@link mergeAll}
  55. *
  56. * @return A function that returns an Observable that converts a higher-order
  57. * Observable into a first-order Observable producing values only from the most
  58. * recent Observable sequence.
  59. */
  60. export declare function switchAll<O extends ObservableInput<any>>(): OperatorFunction<O, ObservedValueOf<O>>;
  61. //# sourceMappingURL=switchAll.d.ts.map