Subtheme of barrio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
9.8 KiB

{"version":3,"file":"onErrorResumeNext.js","sourceRoot":"","sources":["../../src/operators/onErrorResumeNext.ts"],"names":[],"mappings":";;;;;;AACA,+BAA+B,8BAA8B,CAAC,CAAA;AAG9D,wBAAwB,iBAAiB,CAAC,CAAA;AAC1C,gCAAgC,oBAAoB,CAAC,CAAA;AAErD,kCAAkC,2BAA2B,CAAC,CAAA;AAW9D,mCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH;IAAwC,qBAE8C;SAF9C,WAE8C,CAF9C,sBAE8C,CAF9C,IAE8C;QAF9C,oCAE8C;;IACpF,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,iBAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,WAAW,GAA2B,WAAW,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,IAAI,yBAAyB,CAAO,WAAW,CAAC,CAAC,EAA7D,CAA6D,CAAC;AAClG,CAAC;AARe,yBAAiB,oBAQhC,CAAA;AAWD,mCAAmC;AAEnC;IAA8C,qBAE+C;SAF/C,WAE+C,CAF/C,sBAE+C,CAF/C,IAE+C;QAF/C,oCAE+C;;IAC3F,IAAI,MAAM,GAAyB,IAAI,CAAC;IAExC,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,iBAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,WAAW,GAAgC,WAAW,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC;IAE7B,MAAM,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C9B,CAAC;IACH,CAAC;IACH,kCAAC;AAAD,CAAC,AA9BD,CAAgD,iCAAe,GA8B9D","sourcesContent":["import { Observable, 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<T, R>(v: ObservableInput<R>): OperatorFunction<T, R>;\nexport function onErrorResumeNext<T, T2, T3, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>): OperatorFunction<T, R>;\nexport function onErrorResumeNext<T, T2, T3, T4, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): OperatorFunction<T, R>;\nexport function onErrorResumeNext<T, T2, T3, T4, T5, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): OperatorFunction<T, R>;\nexport function onErrorResumeNext<T, T2, T3, T4, T5, T6, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): OperatorFunction<T, R> ;\nexport function onErrorResumeNext<T, R>(...observables: Array<ObservableInput<any> | ((...values: Array<any>) => R)>): OperatorFunction<T, R>;\nexport function onErrorResumeNext<T, R>(array: ObservableInput<any>[]): OperatorFunction<T, R>;\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 * <span class=\"informal\">Execute series of Observables no matter what, even if it means swallowing errors.</span>\n *\n * <img src=\"./img/onErrorResumeNext.png\" width=\"100%\">\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 <caption>Subscribe to the next Observable after map fails</caption>\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<T, R>(...nextSources: Array<ObservableInput<any> |\n Array<ObservableInput<any>> |\n ((...values: Array<any>) => R)>): OperatorFunction<T, R> {\n if (nextSources.length === 1 && isArray(nextSources[0])) {\n nextSources = <Array<Observable<any>>>nextSources[0];\n }\n\n return (source: Observable<T>) => source.lift(new OnErrorResumeNextOperator<T, R>(nextSources));\n}\n\n/* tslint:disable:max-line-length */\nexport function onErrorResumeNextStatic<R>(v: ObservableInput<R>): Observable<R>;\nexport function onErrorResumeNextStatic<T2, T3, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>): Observable<R>;\nexport function onErrorResumeNextStatic<T2, T3, T4, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): Observable<R>;\nexport function onErrorResumeNextStatic<T2, T3, T4, T5, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): Observable<R>;\nexport function onErrorResumeNextStatic<T2, T3, T4, T5, T6, R>(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): Observable<R>;\n\nexport function onErrorResumeNextStatic<R>(...observables: Array<ObservableInput<any> | ((...values: Array<any>) => R)>): Observable<R>;\nexport function onErrorResumeNextStatic<R>(array: ObservableInput<any>[]): Observable<R>;\n/* tslint:enable:max-line-length */\n\nexport function onErrorResumeNextStatic<T, R>(...nextSources: Array<ObservableInput<any> |\n Array<ObservableInput<any>> |\n ((...values: Array<any>) => R)>): Observable<R> {\n let source: ObservableInput<any> = null;\n\n if (nextSources.length === 1 && isArray(nextSources[0])) {\n nextSources = <Array<ObservableInput<any>>>nextSources[0];\n }\n source = nextSources.shift();\n\n return new FromObservable(source, null).lift(new OnErrorResumeNextOperator<T, R>(nextSources));\n}\n\nclass OnErrorResumeNextOperator<T, R> implements Operator<T, R> {\n constructor(private nextSources: Array<ObservableInput<any>>) {\n }\n\n call(subscriber: Subscriber<R>, source: any): any {\n return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));\n }\n}\n\nclass OnErrorResumeNextSubscriber<T, R> extends OuterSubscriber<T, R> {\n constructor(protected destination: Subscriber<T>,\n private nextSources: Array<ObservableInput<any>>) {\n super(destination);\n }\n\n notifyError(error: any, innerSub: InnerSubscriber<T, any>): void {\n this.subscribeToNextSource();\n }\n\n notifyComplete(innerSub: InnerSubscriber<T, any>): 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"]}