Like catchErrorJustReturn, it will catch and switch to another observable. The difference is that the recovery observable does not need to immediately emit and terminate. It can continue emitting. Let's start by creating the PublishSubject, and we will also create a recovery sequence as follows:
example(for: "catchError") { let disposeBag = DisposeBag() let pubSubject = PublishSubject<String>() let recoverySeq = PublishSubject<String>()}
We will use the catchError operator on the subject to print out the error and then return the recovery sequence, as shown:
let disposeBag = DisposeBag() let pubSubject = PublishSubject<String>() let recoverySeq = PublishSubject<String>() pubSubject.catchError({ print("Error=", $0) ...