a zip code crypto-currency system good for red ONLY

withLatestFrom.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { withLatestFrom as higherOrder } from '../operators/withLatestFrom';
  2. /* tslint:enable:max-line-length */
  3. /**
  4. * Combines the source Observable with other Observables to create an Observable
  5. * whose values are calculated from the latest values of each, only when the
  6. * source emits.
  7. *
  8. * <span class="informal">Whenever the source Observable emits a value, it
  9. * computes a formula using that value plus the latest values from other input
  10. * Observables, then emits the output of that formula.</span>
  11. *
  12. * <img src="./img/withLatestFrom.png" width="100%">
  13. *
  14. * `withLatestFrom` combines each value from the source Observable (the
  15. * instance) with the latest values from the other input Observables only when
  16. * the source emits a value, optionally using a `project` function to determine
  17. * the value to be emitted on the output Observable. All input Observables must
  18. * emit at least one value before the output Observable will emit a value.
  19. *
  20. * @example <caption>On every click event, emit an array with the latest timer event plus the click event</caption>
  21. * var clicks = Rx.Observable.fromEvent(document, 'click');
  22. * var timer = Rx.Observable.interval(1000);
  23. * var result = clicks.withLatestFrom(timer);
  24. * result.subscribe(x => console.log(x));
  25. *
  26. * @see {@link combineLatest}
  27. *
  28. * @param {ObservableInput} other An input Observable to combine with the source
  29. * Observable. More than one input Observables may be given as argument.
  30. * @param {Function} [project] Projection function for combining values
  31. * together. Receives all values in order of the Observables passed, where the
  32. * first parameter is a value from the source Observable. (e.g.
  33. * `a.withLatestFrom(b, c, (a1, b1, c1) => a1 + b1 + c1)`). If this is not
  34. * passed, arrays will be emitted on the output Observable.
  35. * @return {Observable} An Observable of projected values from the most recent
  36. * values from each input Observable, or an array of the most recent values from
  37. * each input Observable.
  38. * @method withLatestFrom
  39. * @owner Observable
  40. */
  41. export function withLatestFrom(...args) {
  42. return higherOrder(...args)(this);
  43. }
  44. //# sourceMappingURL=withLatestFrom.js.map