Skip to content

catching error with different observable without completing #6927

Answered by josepot
JeromeDeLeon asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @JeromeDeLeon !

Thanks for sharing a code example, that helped me understand your questions.

Passing different observable automatically completes the observable which is not I want to achieve.

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 that of(4) is the same as:

new Observable<number>(observer => {
  observer.next(4);
  observer.complete();
});

I thought returning any result from the the selector would continue the chain.

Not exactly, it will continue with the provided Observable. If the provided Observable completes, then the resulting Observable will complete, …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JeromeDeLeon
Comment options

@voliva
Comment options

@JeromeDeLeon
Comment options

Answer selected by JeromeDeLeon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants