diff --git a/spec/observables/race-spec.ts b/spec/observables/race-spec.ts index b154012f23..263ded380d 100644 --- a/spec/observables/race-spec.ts +++ b/spec/observables/race-spec.ts @@ -35,6 +35,20 @@ describe('Observable.race', () => { expectSubscriptions(e2.subscriptions).toBe(e2subs); }); + it('should race with array of observable', () => { + const e1 = cold('---a-----b-----c----|'); + const e1subs = '^ !'; + const e2 = cold('------x-----y-----z----|'); + const e2subs = '^ !'; + const expected = '---a-----b-----c----|'; + + const result = Observable.race([e1, e2]); + + expectObservable(result).toBe(expected); + expectSubscriptions(e1.subscriptions).toBe(e1subs); + expectSubscriptions(e2.subscriptions).toBe(e2subs); + }); + it('should race hot and hot', () => { const e1 = hot('---a-----b-----c----|'); const e1subs = '^ !'; diff --git a/src/operator/race.ts b/src/operator/race.ts index f9c30854f4..a5675f7c7d 100644 --- a/src/operator/race.ts +++ b/src/operator/race.ts @@ -9,8 +9,10 @@ import { InnerSubscriber } from '../InnerSubscriber'; import { subscribeToResult } from '../util/subscribeToResult'; /* tslint:disable:max-line-length */ +export function race(this: Observable, observables: Array>): Observable; +export function race(this: Observable, observables: Array>): Observable; export function race(this: Observable, ...observables: Array | Array>>): Observable; -export function race(this: Observable, ...observables: Array | Array>>): Observable; +export function race(this: Observable, ...observables: Array | Array>>): Observable; /* tslint:enable:max-line-length */ /** @@ -39,10 +41,12 @@ export function race(this: Observable, ...observables: Array * @name race * @owner Observable */ +export function raceStatic(observables: Array>): Observable; +export function raceStatic(observables: Array>): Observable; export function raceStatic(...observables: Array | Array>>): Observable; export function raceStatic(...observables: Array | Array>>): Observable { // if the only argument is an array, it was most likely called with - // `pair([obs1, obs2, ...])` + // `race([obs1, obs2, ...])` if (observables.length === 1) { if (isArray(observables[0])) { observables = >>observables[0];