Reputation: 576
I have a stream which may or may not error, I would like to catchError in order to return the previous/last value before the error in order to continue the stream and not complete. Something along the lines of this:
inputStream$.pipe(catchError(err => inputStream$.previousValue)).subscribe(...)
Upvotes: 0
Views: 1803
Reputation: 3306
As soon as your observable inputStream$
emits an error it is finished.
catchError
allows to concat an observable which emited an error with another observable (the result of the first parameter of catchError
)
Some examples are available here: https://www.learnrxjs.io/operators/error_handling/catch.html
What you are looking for is probably retry
which re-subscribe to the source observable (here inputSteam$
) when the source emits an error. https://www.learnrxjs.io/operators/error_handling/retry.html
Upvotes: 1