import { Observable } from '../Observable'; import { isArray } from '../util/isArray'; import { MonoTypeOperatorFunction, OperatorFunction } from '../types'; import { race as raceStatic } from '../observable/race'; /* tslint:disable:max-line-length */ /** @deprecated Deprecated in favor of static race. */ export function race(observables: Array>): MonoTypeOperatorFunction; /** @deprecated Deprecated in favor of static race. */ export function race(observables: Array>): OperatorFunction; /** @deprecated Deprecated in favor of static race. */ export function race(...observables: Array | Array>>): MonoTypeOperatorFunction; /** @deprecated Deprecated in favor of static race. */ export function race(...observables: Array | Array>>): OperatorFunction; /* tslint:enable:max-line-length */ /** * Returns an Observable that mirrors the first source Observable to emit a next, * error or complete notification from the combination of this Observable and supplied Observables. * @param {...Observables} ...observables Sources used to race for which Observable emits first. * @return {Observable} An Observable that mirrors the output of the first Observable to emit an item. * @method race * @owner Observable * @deprecated Deprecated in favor of static {@link race}. */ export function race(...observables: (Observable | Observable[])[]): MonoTypeOperatorFunction { return function raceOperatorFunction(source: Observable) { // if the only argument is an array, it was most likely called with // `pair([obs1, obs2, ...])` if (observables.length === 1 && isArray(observables[0])) { observables = observables[0] as Observable[]; } return source.lift.call(raceStatic(source, ...(observables as Observable[]))); }; }