Front end of the Slack clone application.

withLatestFrom.js 2.3KB

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