diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts
index 471963336c..de8f34ee2c 100644
--- a/api_guard/dist/types/index.d.ts
+++ b/api_guard/dist/types/index.d.ts
@@ -499,6 +499,9 @@ export declare function of(...values: A): Observab
export declare function onErrorResumeNext(sources: [...ObservableInputTuple]): Observable;
export declare function onErrorResumeNext(...sources: [...ObservableInputTuple]): Observable;
+export declare function onErrorResumeNextWith(sources: [...ObservableInputTuple]): OperatorFunction;
+export declare function onErrorResumeNextWith(...sources: [...ObservableInputTuple]): OperatorFunction;
+
export interface Operator {
call(subscriber: Subscriber, source: any): TeardownLogic;
}
diff --git a/api_guard/dist/types/operators/index.d.ts b/api_guard/dist/types/operators/index.d.ts
index 4f0b8b61ca..c517a63a25 100644
--- a/api_guard/dist/types/operators/index.d.ts
+++ b/api_guard/dist/types/operators/index.d.ts
@@ -191,8 +191,7 @@ export declare function multicast>(subjectFact
export declare function observeOn(scheduler: SchedulerLike, delay?: number): MonoTypeOperatorFunction;
-export declare function onErrorResumeNext(sources: [...ObservableInputTuple]): OperatorFunction;
-export declare function onErrorResumeNext(...sources: [...ObservableInputTuple]): OperatorFunction;
+export declare const onErrorResumeNext: typeof onErrorResumeNextWith;
export declare function pairwise(): OperatorFunction;
diff --git a/docs_app/content/guide/importing.md b/docs_app/content/guide/importing.md
index b39da4605b..797c038c23 100644
--- a/docs_app/content/guide/importing.md
+++ b/docs_app/content/guide/importing.md
@@ -56,11 +56,12 @@ ending with `With`). Those are:
| [`combineLatest`](/api/operators/combineLatest) | {@link combineLatest} | {@link combineLatestWith} |
| [`concat`](/api/operators/concat) | {@link concat} | {@link concatWith} |
| [`merge`](/api/operators/merge) | {@link merge} | {@link mergeWith} |
-| [`onErrorResumeNext`](/api/operators/onErrorResumeNext) | {@link onErrorResumeNext} | - |
-| [`partition`](/api/operators/partition) | {@link partition} | - |
+| [`onErrorResumeNext`](/api/operators/onErrorResumeNext) | {@link onErrorResumeNext} | {@link onErrorResumeNextWith} |
| [`race`](/api/operators/race) | {@link race} | {@link raceWith} |
| [`zip`](/api/operators/zip) | {@link zip} | {@link zipWith} |
+`partition`, the operator, is a special case, as it is deprecated and you should be using the `partition` creation function exported from `'rxjs'` instead.
+
For example, the old and deprecated way of using [`merge`](/api/operators/merge) from `'rxjs/operators'`
is:
diff --git a/src/index.ts b/src/index.ts
index 759b3103af..e267a62548 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -155,6 +155,7 @@ export { mergeWith } from './internal/operators/mergeWith';
export { min } from './internal/operators/min';
export { multicast } from './internal/operators/multicast';
export { observeOn } from './internal/operators/observeOn';
+export { onErrorResumeNextWith } from './internal/operators/onErrorResumeNextWith';
export { pairwise } from './internal/operators/pairwise';
export { pluck } from './internal/operators/pluck';
export { publish } from './internal/operators/publish';
diff --git a/src/internal/observable/onErrorResumeNext.ts b/src/internal/observable/onErrorResumeNext.ts
index 60fbceca39..ef62c033a1 100644
--- a/src/internal/observable/onErrorResumeNext.ts
+++ b/src/internal/observable/onErrorResumeNext.ts
@@ -1,8 +1,9 @@
import { Observable } from '../Observable';
import { ObservableInputTuple } from '../types';
-import { EMPTY } from './empty';
-import { onErrorResumeNext as onErrorResumeNextWith } from '../operators/onErrorResumeNext';
import { argsOrArgArray } from '../util/argsOrArgArray';
+import { OperatorSubscriber } from '../operators/OperatorSubscriber';
+import { noop } from '../util/noop';
+import { innerFrom } from './innerFrom';
/* tslint:disable:max-line-length */
export function onErrorResumeNext(sources: [...ObservableInputTuple]): Observable;
@@ -75,5 +76,26 @@ export function onErrorResumeNext(...sources: [...
export function onErrorResumeNext(
...sources: [[...ObservableInputTuple]] | [...ObservableInputTuple]
): Observable {
- return onErrorResumeNextWith(argsOrArgArray(sources))(EMPTY);
+ const nextSources: ObservableInputTuple = argsOrArgArray(sources) as any;
+
+ return new Observable((subscriber) => {
+ let sourceIndex = 0;
+ const subscribeNext = () => {
+ if (sourceIndex < nextSources.length) {
+ let nextSource: Observable;
+ try {
+ nextSource = innerFrom(nextSources[sourceIndex++]);
+ } catch (err) {
+ subscribeNext();
+ return;
+ }
+ const innerSubscriber = new OperatorSubscriber(subscriber, undefined, noop, noop);
+ nextSource.subscribe(innerSubscriber);
+ innerSubscriber.add(subscribeNext);
+ } else {
+ subscriber.complete();
+ }
+ };
+ subscribeNext();
+ });
}
diff --git a/src/internal/operators/onErrorResumeNext.ts b/src/internal/operators/onErrorResumeNextWith.ts
similarity index 72%
rename from src/internal/operators/onErrorResumeNext.ts
rename to src/internal/operators/onErrorResumeNextWith.ts
index e248fb51fa..9bcac812a4 100644
--- a/src/internal/operators/onErrorResumeNext.ts
+++ b/src/internal/operators/onErrorResumeNextWith.ts
@@ -1,15 +1,11 @@
-import { Observable } from '../Observable';
import { ObservableInputTuple, OperatorFunction } from '../types';
-import { operate } from '../util/lift';
-import { innerFrom } from '../observable/innerFrom';
import { argsOrArgArray } from '../util/argsOrArgArray';
-import { createOperatorSubscriber } from './OperatorSubscriber';
-import { noop } from '../util/noop';
+import { onErrorResumeNext as oERNCreate } from '../observable/onErrorResumeNext';
-export function onErrorResumeNext(
+export function onErrorResumeNextWith(
sources: [...ObservableInputTuple]
): OperatorFunction;
-export function onErrorResumeNext(
+export function onErrorResumeNextWith(
...sources: [...ObservableInputTuple]
): OperatorFunction;
@@ -85,7 +81,7 @@ export function onErrorResumeNext(
* Observable, but - if it errors - subscribes to the next passed Observable
* and so on, until it completes or runs out of Observables.
*/
-export function onErrorResumeNext(
+export function onErrorResumeNextWith(
...sources: [[...ObservableInputTuple]] | [...ObservableInputTuple]
): OperatorFunction {
// For some reason, TS 4.1 RC gets the inference wrong here and infers the
@@ -94,32 +90,10 @@ export function onErrorResumeNext(
// asserted explicitly.
const nextSources = argsOrArgArray(sources) as unknown as ObservableInputTuple;
- return operate((source, subscriber) => {
- const remaining = [source, ...nextSources];
- const subscribeNext = () => {
- if (!subscriber.closed) {
- if (remaining.length > 0) {
- let nextSource: Observable;
- try {
- nextSource = innerFrom(remaining.shift()!);
- } catch (err) {
- subscribeNext();
- return;
- }
-
- // Here we have to use one of our Subscribers, or it does not wire up
- // The `closed` property of upstream Subscribers synchronously, that
- // would result in situation were we could not stop a synchronous firehose
- // with something like `take(3)`.
- const innerSub = createOperatorSubscriber(subscriber, undefined, noop, noop);
- nextSource.subscribe(innerSub);
- innerSub.add(subscribeNext);
- } else {
- subscriber.complete();
- }
- }
- };
-
- subscribeNext();
- });
+ return (source) => oERNCreate(source, ...nextSources);
}
+
+/**
+ * @deprecated Renamed. Use {@link onErrorResumeNextWith} instead. Will be removed in v8.
+ */
+export const onErrorResumeNext = onErrorResumeNextWith;
diff --git a/src/operators/index.ts b/src/operators/index.ts
index 9272c89780..ebd6d60254 100644
--- a/src/operators/index.ts
+++ b/src/operators/index.ts
@@ -57,7 +57,7 @@ export { mergeWith } from '../internal/operators/mergeWith';
export { min } from '../internal/operators/min';
export { multicast } from '../internal/operators/multicast';
export { observeOn } from '../internal/operators/observeOn';
-export { onErrorResumeNext } from '../internal/operators/onErrorResumeNext';
+export { onErrorResumeNext } from '../internal/operators/onErrorResumeNextWith';
export { pairwise } from '../internal/operators/pairwise';
export { partition } from '../internal/operators/partition';
export { pluck } from '../internal/operators/pluck';