Why does Rxjs unsubscribe on error?

Viewed 8691

In short: How to proceed listening after an error in stream without putting a .catch before every .subscribe?

If you need more details they are here:

Lets assume I have a Subject of current user or null. I get the data from API sometimes and send to the Subject. It updates the view accordingly. But at some point error occurs on my server and I want my application to continue working as before but notify some places about the error and KEEP listening to my Subject.

Initially I thought that if I just do userSubject.error(...) it will only trigger .catch callback and error handlers on subscribes and skip all success handlers and chains. And if after I call userSubject.next(...) all my chains and subscribers will work as before

BUT unluckily it is not the case. After the first uncaught .error it unsubscribes subscribers from the stream and they do not operate any more.

So my question: Why??? And what to do instead if I want to handle null value normally but also handle errors only in some places?

Here is the link to RxJs source code where Subscriber unsubscribes on error https://github.com/ReactiveX/rxjs/blob/master/src/Subscriber.ts#L140

2 Answers
Related