a zip code crypto-currency system good for red ONLY

combineLatest.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /** PURE_IMPORTS_START .._operators_combineLatest PURE_IMPORTS_END */
  2. import { combineLatest as higherOrder } from '../operators/combineLatest';
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Combines multiple Observables to create an Observable whose values are
  6. * calculated from the latest values of each of its input Observables.
  7. *
  8. * <span class="informal">Whenever any input Observable emits a value, it
  9. * computes a formula using the latest values from all the inputs, then emits
  10. * the output of that formula.</span>
  11. *
  12. * <img src="./img/combineLatest.png" width="100%">
  13. *
  14. * `combineLatest` combines the values from this Observable with values from
  15. * Observables passed as arguments. This is done by subscribing to each
  16. * Observable, in order, and collecting an array of each of the most recent
  17. * values any time any of the input Observables emits, then either taking that
  18. * array and passing it as arguments to an optional `project` function and
  19. * emitting the return value of that, or just emitting the array of recent
  20. * values directly if there is no `project` function.
  21. *
  22. * @example <caption>Dynamically calculate the Body-Mass Index from an Observable of weight and one for height</caption>
  23. * var weight = Rx.Observable.of(70, 72, 76, 79, 75);
  24. * var height = Rx.Observable.of(1.76, 1.77, 1.78);
  25. * var bmi = weight.combineLatest(height, (w, h) => w / (h * h));
  26. * bmi.subscribe(x => console.log('BMI is ' + x));
  27. *
  28. * // With output to console:
  29. * // BMI is 24.212293388429753
  30. * // BMI is 23.93948099205209
  31. * // BMI is 23.671253629592222
  32. *
  33. * @see {@link combineAll}
  34. * @see {@link merge}
  35. * @see {@link withLatestFrom}
  36. *
  37. * @param {ObservableInput} other An input Observable to combine with the source
  38. * Observable. More than one input Observables may be given as argument.
  39. * @param {function} [project] An optional function to project the values from
  40. * the combined latest values into a new value on the output Observable.
  41. * @return {Observable} An Observable of projected values from the most recent
  42. * values from each input Observable, or an array of the most recent values from
  43. * each input Observable.
  44. * @method combineLatest
  45. * @owner Observable
  46. */
  47. export function combineLatest() {
  48. var observables = [];
  49. for (var _i = 0; _i < arguments.length; _i++) {
  50. observables[_i - 0] = arguments[_i];
  51. }
  52. return higherOrder.apply(void 0, observables)(this);
  53. }
  54. //# sourceMappingURL=combineLatest.js.map