import { Observable } from '../Observable';
import { Subscriber } from '../Subscriber';
import { Subscription } from '../Subscription';
-import { OuterSubscriber } from '../OuterSubscriber';
-import { InnerSubscriber } from '../InnerSubscriber';
-import { subscribeToResult } from '../util/subscribeToResult';
import { ObservableInput, OperatorFunction, ObservedValueOf } from '../types';
import { map } from './map';
import { from } from '../observable/from';
+import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
/* tslint:disable:max-line-length */
export function exhaustMap<T, O extends ObservableInput<any>>(project: (value: T, index: number) => O): OperatorFunction<T, ObservedValueOf<O>>;
* @ignore
* @extends {Ignored}
*/
-class ExhaustMapSubscriber<T, R> extends OuterSubscriber<T, R> {
+class ExhaustMapSubscriber<T, R> extends SimpleOuterSubscriber<T, R> {
private hasSubscription = false;
private hasCompleted = false;
private index = 0;
try {
result = this.project(value, index);
} catch (err) {
- this.destination.error(err);
+ this.destination.error!(err);
return;
}
this.hasSubscription = true;
- this._innerSub(result, value, index);
+ this._innerSub(result);
}
- private _innerSub(result: ObservableInput<R>, value: T, index: number): void {
- const innerSubscriber = new InnerSubscriber(this, value, index);
+ private _innerSub(result: ObservableInput<R>): void {
+ const innerSubscriber = new SimpleInnerSubscriber(this);
const destination = this.destination as Subscription;
destination.add(innerSubscriber);
- const innerSubscription = subscribeToResult<T, R>(this, result, undefined, undefined, innerSubscriber);
+ const innerSubscription = innerSubscribe(result, innerSubscriber);
// The returned subscription will usually be the subscriber that was
// passed. However, interop subscribers will be wrapped and for
// unsubscriptions to chain correctly, the wrapper needs to be added, too.
protected _complete(): void {
this.hasCompleted = true;
if (!this.hasSubscription) {
- this.destination.complete();
+ this.destination.complete!();
}
this.unsubscribe();
}
- notifyNext(outerValue: T, innerValue: R,
- outerIndex: number, innerIndex: number,
- innerSub: InnerSubscriber<T, R>): void {
- this.destination.next(innerValue);
+ notifyNext(innerValue: R): void {
+ this.destination.next!(innerValue);
}
notifyError(err: any): void {
- this.destination.error(err);
+ this.destination.error!(err);
}
- notifyComplete(innerSub: Subscription): void {
- const destination = this.destination as Subscription;
- destination.remove(innerSub);
-
+ notifyComplete(): void {
this.hasSubscription = false;
if (this.hasCompleted) {
- this.destination.complete();
+ this.destination.complete!();
}
}
}