catching error with different observable without completing #6927
-
Let's say I have subject that emits incremental value and throws an error at some point but I still want to continue the emission say when it catches an error, instead of retrying or rethrowing, I pass default value. Here's the code sample. Passing different observable automatically completes the observable which is not I want to achieve. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @JeromeDeLeon ! Thanks for sharing a code example, that helped me understand your questions.
That's because the observable to that you were returning inside the selector function of new Observable<number>(observer => {
observer.next(4);
observer.complete();
});
Not exactly, it will continue with the provided Observable. If the provided Observable completes, then the resulting Observable will complete, if it doesn't, then the returning Observable won't complete.
Sure, there are many ways to accomplish the same thing. For instance: catchError((err, caught) => concat(of(4), caught))
Apologies, but I don't quite understand what you mean here. |
Beta Was this translation helpful? Give feedback.
Hi @JeromeDeLeon !
Thanks for sharing a code example, that helped me understand your questions.
That's because the observable to that you were returning inside the selector function of
catchError
(of(4)
) is an Observable that emits and then completes. Meaning thatof(4)
is the same as:Not exactly, it will continue with the provided Observable. If the provided Observable completes, then the resulting Observable will complete, …