53 lines
1.9 KiB
TypeScript

import { Observable } from '../Observable';
import { Operator } from '../Operator';
import { Subscriber } from '../Subscriber';
import { TeardownLogic } from '../types';
import { OuterSubscriber } from '../OuterSubscriber';
import { InnerSubscriber } from '../InnerSubscriber';
/**
* Returns an Observable that mirrors the first source Observable to emit an item.
*
* ## Example
* ### Subscribes to the observable that was the first to start emitting.
*
* ```javascript
* const obs1 = interval(1000).pipe(mapTo('fast one'));
* const obs2 = interval(3000).pipe(mapTo('medium one'));
* const obs3 = interval(5000).pipe(mapTo('slow one'));
*
* race(obs3, obs1, obs2)
* .subscribe(
* winner => console.log(winner)
* );
*
* // result:
* // a series of 'fast one'
* ```
*
* @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.
* @static true
* @name race
* @owner Observable
*/
export declare function race<T>(observables: Array<Observable<T>>): Observable<T>;
export declare function race<T>(observables: Array<Observable<any>>): Observable<T>;
export declare function race<T>(...observables: Array<Observable<T> | Array<Observable<T>>>): Observable<T>;
export declare class RaceOperator<T> implements Operator<T, T> {
call(subscriber: Subscriber<T>, source: any): TeardownLogic;
}
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
export declare class RaceSubscriber<T> extends OuterSubscriber<T, T> {
private hasFirst;
private observables;
private subscriptions;
constructor(destination: Subscriber<T>);
protected _next(observable: any): void;
protected _complete(): void;
notifyNext(outerValue: T, innerValue: T, outerIndex: number, innerIndex: number, innerSub: InnerSubscriber<T, T>): void;
}