race.js 1.2KB

12345678910111213141516171819202122232425262728
  1. /** PURE_IMPORTS_START .._util_isArray,.._observable_race PURE_IMPORTS_END */
  2. import { isArray } from '../util/isArray';
  3. import { race as raceStatic } from '../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. export 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(observables[0])) {
  22. observables = observables[0];
  23. }
  24. return source.lift.call(raceStatic.apply(void 0, [source].concat(observables)));
  25. };
  26. }
  27. //# sourceMappingURL=race.js.map