61b80fa2051760e73b6e654afe780b06163a2dc0d3605fccad6bd29d338428805748729499eef401662e32a0fbedbdfd4e20e7b89b9daade2b698d8425497d 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { ObservableInputTuple, OperatorFunction, Cons } from '../types';
  2. /**
  3. * Create an observable that combines the latest values from all passed observables and the source
  4. * into arrays and emits them.
  5. *
  6. * Returns an observable, that when subscribed to, will subscribe to the source observable and all
  7. * sources provided as arguments. Once all sources emit at least one value, all of the latest values
  8. * will be emitted as an array. After that, every time any source emits a value, all of the latest values
  9. * will be emitted as an array.
  10. *
  11. * This is a useful operator for eagerly calculating values based off of changed inputs.
  12. *
  13. * ## Example
  14. *
  15. * Simple concatenation of values from two inputs
  16. *
  17. * ```ts
  18. * import { fromEvent, combineLatestWith, map } from 'rxjs';
  19. *
  20. * // Setup: Add two inputs to the page
  21. * const input1 = document.createElement('input');
  22. * document.body.appendChild(input1);
  23. * const input2 = document.createElement('input');
  24. * document.body.appendChild(input2);
  25. *
  26. * // Get streams of changes
  27. * const input1Changes$ = fromEvent(input1, 'change');
  28. * const input2Changes$ = fromEvent(input2, 'change');
  29. *
  30. * // Combine the changes by adding them together
  31. * input1Changes$.pipe(
  32. * combineLatestWith(input2Changes$),
  33. * map(([e1, e2]) => (<HTMLInputElement>e1.target).value + ' - ' + (<HTMLInputElement>e2.target).value)
  34. * )
  35. * .subscribe(x => console.log(x));
  36. * ```
  37. *
  38. * @param otherSources the other sources to subscribe to.
  39. * @return A function that returns an Observable that emits the latest
  40. * emissions from both source and provided Observables.
  41. */
  42. export declare function combineLatestWith<T, A extends readonly unknown[]>(...otherSources: [...ObservableInputTuple<A>]): OperatorFunction<T, Cons<T, A>>;
  43. //# sourceMappingURL=combineLatestWith.d.ts.map