import { Subscriber } from '../Subscriber';
import { Subscription } from '../Subscription';
import { isArray } from '../util/isArray';
-import { OuterSubscriber } from '../OuterSubscriber';
-import { InnerSubscriber } from '../InnerSubscriber';
-import { subscribeToResult } from '../util/subscribeToResult';
import { ObservableInput, OperatorFunction } from '../types';
+import { SimpleOuterSubscriber, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';
/* tslint:disable:max-line-length */
export function onErrorResumeNext<T>(): OperatorFunction<T, T>;
export function onErrorResumeNextStatic<T, R>(...nextSources: Array<ObservableInput<any> |
Array<ObservableInput<any>> |
((...values: Array<any>) => R)>): Observable<R> {
- let source: ObservableInput<any> = null;
+ let source: ObservableInput<any>|undefined = undefined;
if (nextSources.length === 1 && isArray(nextSources[0])) {
- nextSources = <Array<ObservableInput<any>>>nextSources[0];
+ nextSources = nextSources[0] as ObservableInput<any>[];
}
- source = nextSources.shift();
+ // TODO: resolve issue with passing no arguments.
+ source = nextSources.shift()!;
- return from(source, null).lift(new OnErrorResumeNextOperator<T, R>(nextSources));
+ return from(source).lift(new OnErrorResumeNextOperator<T, R>(nextSources));
}
class OnErrorResumeNextOperator<T, R> implements Operator<T, R> {
}
}
-class OnErrorResumeNextSubscriber<T, R> extends OuterSubscriber<T, R> {
+class OnErrorResumeNextSubscriber<T, R> extends SimpleOuterSubscriber<T, R> {
constructor(protected destination: Subscriber<T>,
private nextSources: Array<ObservableInput<any>>) {
super(destination);
}
- notifyError(error: any, innerSub: InnerSubscriber<T, any>): void {
+ notifyError(): void {
this.subscribeToNextSource();
}
- notifyComplete(innerSub: InnerSubscriber<T, any>): void {
+ notifyComplete(): void {
this.subscribeToNextSource();
}
private subscribeToNextSource(): void {
const next = this.nextSources.shift();
if (!!next) {
- const innerSubscriber = new InnerSubscriber(this, undefined, undefined);
+ const innerSubscriber = new SimpleInnerSubscriber(this);
const destination = this.destination as Subscription;
destination.add(innerSubscriber);
- const innerSubscription = subscribeToResult(this, next, undefined, undefined, innerSubscriber);
+ const innerSubscription = innerSubscribe(next, 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.