race.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. var isArray_1 = require('../util/isArray');
  3. var race_1 = require('../observable/race');
  4. /* tslint:enable:max-line-length */
  5. /**
  6. * Returns an Observable that mirrors the first source Observable to emit an item
  7. * from the combination of this Observable and supplied Observables.
  8. * @param {...Observables} ...observables Sources used to race for which Observable emits first.
  9. * @return {Observable} An Observable that mirrors the output of the first Observable to emit an item.
  10. * @method race
  11. * @owner Observable
  12. */
  13. function race() {
  14. var observables = [];
  15. for (var _i = 0; _i < arguments.length; _i++) {
  16. observables[_i - 0] = arguments[_i];
  17. }
  18. return function raceOperatorFunction(source) {
  19. // if the only argument is an array, it was most likely called with
  20. // `pair([obs1, obs2, ...])`
  21. if (observables.length === 1 && isArray_1.isArray(observables[0])) {
  22. observables = observables[0];
  23. }
  24. return source.lift.call(race_1.race.apply(void 0, [source].concat(observables)));
  25. };
  26. }
  27. exports.race = race;
  28. //# sourceMappingURL=race.js.map