race.js 964 B

12345678910111213141516171819202122
  1. import { isArray } from '../util/isArray';
  2. import { race as raceStatic } from '../observable/race';
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Returns an Observable that mirrors the first source Observable to emit an item
  6. * from the combination of this Observable and supplied Observables.
  7. * @param {...Observables} ...observables Sources used to race for which Observable emits first.
  8. * @return {Observable} An Observable that mirrors the output of the first Observable to emit an item.
  9. * @method race
  10. * @owner Observable
  11. */
  12. export function race(...observables) {
  13. return function raceOperatorFunction(source) {
  14. // if the only argument is an array, it was most likely called with
  15. // `pair([obs1, obs2, ...])`
  16. if (observables.length === 1 && isArray(observables[0])) {
  17. observables = observables[0];
  18. }
  19. return source.lift.call(raceStatic(source, ...observables));
  20. };
  21. }
  22. //# sourceMappingURL=race.js.map