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, ObservableInput } from '../Observable';\nimport { FromObservable } from '../observable/FromObservable';\nimport { Operator } from '../Operator';\nimport { Subscriber } from '../Subscriber';\nimport { isArray } from '../util/isArray';\nimport { OuterSubscriber } from '../OuterSubscriber';\nimport { InnerSubscriber } from '../InnerSubscriber';\nimport { subscribeToResult } from '../util/subscribeToResult';\nimport { OperatorFunction } from '../interfaces';\n\n/* tslint:disable:max-line-length */\nexport function onErrorResumeNext(v: ObservableInput): OperatorFunction;\nexport function onErrorResumeNext(v2: ObservableInput, v3: ObservableInput): OperatorFunction;\nexport function onErrorResumeNext(v2: ObservableInput, v3: ObservableInput, v4: ObservableInput): OperatorFunction;\nexport function onErrorResumeNext(v2: ObservableInput, v3: ObservableInput, v4: ObservableInput, v5: ObservableInput): OperatorFunction;\nexport function onErrorResumeNext(v2: ObservableInput, v3: ObservableInput, v4: ObservableInput, v5: ObservableInput, v6: ObservableInput): OperatorFunction ;\nexport function onErrorResumeNext(...observables: Array | ((...values: Array) => R)>): OperatorFunction;\nexport function onErrorResumeNext(array: ObservableInput[]): OperatorFunction;\n/* tslint:enable:max-line-length */\n\n/**\n * When any of the provided Observable emits an complete or error notification, it immediately subscribes to the next one\n * that was passed.\n *\n * Execute series of Observables no matter what, even if it means swallowing errors.\n *\n * \n *\n * `onErrorResumeNext` is an operator that accepts a series of Observables, provided either directly as\n * arguments or as an array. If no single Observable is provided, returned Observable will simply behave the same\n * as the source.\n *\n * `onErrorResumeNext` returns an Observable that starts by subscribing and re-emitting values from the source Observable.\n * When its stream of values ends - no matter if Observable completed or emitted an error - `onErrorResumeNext`\n * will subscribe to the first Observable that was passed as an argument to the method. It will start re-emitting\n * its values as well and - again - when that stream ends, `onErrorResumeNext` will proceed to subscribing yet another\n * Observable in provided series, no matter if previous Observable completed or ended with an error. This will\n * be happening until there is no more Observables left in the series, at which point returned Observable will\n * complete - even if the last subscribed stream ended with an error.\n *\n * `onErrorResumeNext` can be therefore thought of as version of {@link concat} operator, which is more permissive\n * when it comes to the errors emitted by its input Observables. While `concat` subscribes to the next Observable\n * in series only if previous one successfully completed, `onErrorResumeNext` subscribes even if it ended with\n * an error.\n *\n * Note that you do not get any access to errors emitted by the Observables. In particular do not\n * expect these errors to appear in error callback passed to {@link subscribe}. If you want to take\n * specific actions based on what error was emitted by an Observable, you should try out {@link catch} instead.\n *\n *\n * @example Subscribe to the next Observable after map fails\n * Rx.Observable.of(1, 2, 3, 0)\n * .map(x => {\n * if (x === 0) { throw Error(); }\n return 10 / x;\n * })\n * .onErrorResumeNext(Rx.Observable.of(1, 2, 3))\n * .subscribe(\n * val => console.log(val),\n * err => console.log(err), // Will never be called.\n * () => console.log('that\\'s it!')\n * );\n *\n * // Logs:\n * // 10\n * // 5\n * // 3.3333333333333335\n * // 1\n * // 2\n * // 3\n * // \"that's it!\"\n *\n * @see {@link concat}\n * @see {@link catch}\n *\n * @param {...ObservableInput} observables Observables passed either directly or as an array.\n * @return {Observable} An Observable that emits values from source Observable, but - if it errors - subscribes\n * to the next passed Observable and so on, until it completes or runs out of Observables.\n * @method onErrorResumeNext\n * @owner Observable\n */\n\nexport function onErrorResumeNext(...nextSources: Array |\n Array> |\n ((...values: Array) => R)>): OperatorFunction {\n if (nextSources.length === 1 && isArray(nextSources[0])) {\n nextSources = >>nextSources[0];\n }\n\n return (source: Observable) => source.lift(new OnErrorResumeNextOperator(nextSources));\n}\n\n/* tslint:disable:max-line-length */\nexport function onErrorResumeNextStatic(v: ObservableInput): Observable;\nexport function onErrorResumeNextStatic(v2: ObservableInput, v3: ObservableInput): Observable;\nexport function onErrorResumeNextStatic(v2: ObservableInput, v3: ObservableInput, v4: ObservableInput): Observable;\nexport function onErrorResumeNextStatic(v2: ObservableInput, v3: ObservableInput, v4: ObservableInput, v5: ObservableInput): Observable;\nexport function onErrorResumeNextStatic(v2: ObservableInput, v3: ObservableInput, v4: ObservableInput, v5: ObservableInput, v6: ObservableInput): Observable;\n\nexport function onErrorResumeNextStatic(...observables: Array | ((...values: Array) => R)>): Observable;\nexport function onErrorResumeNextStatic(array: ObservableInput[]): Observable;\n/* tslint:enable:max-line-length */\n\nexport function onErrorResumeNextStatic(...nextSources: Array |\n Array> |\n ((...values: Array) => R)>): Observable {\n let source: ObservableInput = null;\n\n if (nextSources.length === 1 && isArray(nextSources[0])) {\n nextSources = >>nextSources[0];\n }\n source = nextSources.shift();\n\n return new FromObservable(source, null).lift(new OnErrorResumeNextOperator(nextSources));\n}\n\nclass OnErrorResumeNextOperator implements Operator {\n constructor(private nextSources: Array>) {\n }\n\n call(subscriber: Subscriber, source: any): any {\n return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));\n }\n}\n\nclass OnErrorResumeNextSubscriber extends OuterSubscriber {\n constructor(protected destination: Subscriber,\n private nextSources: Array>) {\n super(destination);\n }\n\n notifyError(error: any, innerSub: InnerSubscriber): void {\n this.subscribeToNextSource();\n }\n\n notifyComplete(innerSub: InnerSubscriber): void {\n this.subscribeToNextSource();\n }\n\n protected _error(err: any): void {\n this.subscribeToNextSource();\n }\n\n protected _complete(): void {\n this.subscribeToNextSource();\n }\n\n private subscribeToNextSource(): void {\n const next = this.nextSources.shift();\n if (next) {\n this.add(subscribeToResult(this, next));\n } else {\n this.destination.complete();\n }\n }\n}\n"]}