onErrorResumeNext

When any of the provided Observable emits an complete or error notification, it immediately subscribes to the next one that was passed.

onErrorResumeNext<T, R>(...sources: Array<ObservableInput<any> | Array<ObservableInput<any>> | ((...values: Array<any>) => R)>): Observable<R>

Parameters

sources

Observables (or anything that is observable) passed either directly or as an array.

Returns

Observable<R>: An Observable that concatenates all sources, one after the other, ignoring all errors, such that any error causes it to move on to the next source.

Description

Execute series of Observables no matter what, even if it means swallowing errors.

onErrorResumeNext Will subscribe to each observable source it is provided, in order. If the source it's subscribed to emits an error or completes, it will move to the next source without error.

If onErrorResumeNext is provided no arguments, or a single, empty array, it will return EMPTY.

onErrorResumeNext is basically concat, only it will continue, even if one of its sources emits an error.

Note that there is no way to handle any errors thrown by sources via the resuult of onErrorResumeNext. If you want to handle errors thrown in any given source, you can always use the catchError operator on them before passing them into onErrorResumeNext.

Example

Subscribe to the next Observable after map fails

import { onErrorResumeNext, of } from 'rxjs'; import { map } from 'rxjs/operators'; onErrorResumeNext( of(1, 2, 3, 0).pipe( map(x => { if (x === 0) throw Error(); return 10 / x; }) ), of(1, 2, 3), ) .subscribe( val => console.log(val), err => console.log(err), // Will never be called. () => console.log('done'), ); // Logs: // 10 // 5 // 3.3333333333333335 // 1 // 2 // 3 // "done"

Overloads

onErrorResumeNext(v: ObservableInput<R>): Observable<R>

Parameters

v

Type: ObservableInput.

Returns

Observable<R>

onErrorResumeNext(v2: ObservableInput<T2>, v3: ObservableInput<T3>): Observable<R>

Parameters

v2

Type: ObservableInput.

v3

Type: ObservableInput.

Returns

Observable<R>

onErrorResumeNext(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>): Observable<R>

Parameters

v2

Type: ObservableInput.

v3

Type: ObservableInput.

v4

Type: ObservableInput.

Returns

Observable<R>

onErrorResumeNext(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>): Observable<R>

Parameters

v2

Type: ObservableInput.

v3

Type: ObservableInput.

v4

Type: ObservableInput.

v5

Type: ObservableInput.

Returns

Observable<R>

onErrorResumeNext(v2: ObservableInput<T2>, v3: ObservableInput<T3>, v4: ObservableInput<T4>, v5: ObservableInput<T5>, v6: ObservableInput<T6>): Observable<R>

Parameters

v2

Type: ObservableInput.

v3

Type: ObservableInput.

v4

Type: ObservableInput.

v5

Type: ObservableInput.

v6

Type: ObservableInput.

Returns

Observable<R>

onErrorResumeNext(...observables: Array<ObservableInput<any> | ((...values: Array<any>) => R)>): Observable<R>

Parameters

observables

Type: Array | ((...values: Array) => R)>.

Returns

Observable<R>

onErrorResumeNext(array: ObservableInput<any>[]): Observable<R>

Parameters

array

Type: ObservableInput[].

Returns

Observable<R>

See Also