Let's just copy and paste the last example and change the description as follows:
example(for: "Driver onErrorDriveWith"){ let disposeBag = DisposeBag() let pubSubject = PublishSubject<Int>() pubSubject.asDriver(onErrorJustReturn: 1000) .drive(onNext: { print ( $0 ) }) .disposed(by: disposeBag) pubSubject.onNext(10) pubSubject.onNext(20) pubSubject.onError(CustomError.test)}
We will also create a recovery subject and change the asDriver call to use onErrorDriver using the recover subject, which also has to specify what needs to be done on error. So we will also just return 1000, as follows:
example(for: "Driver onErrorDriveWith"){ let disposeBag = DisposeBag() let pubSubject = PublishSubject<Int>() let recoverySubject ...