RxSwift: `catchError` behavior only tied to latest observable sequence???
Hey guys,
I have problems in understanding error catching and continuing the observable sequence in case of an error.
I now have some sequences like this one:
function doManyThings() -> Observable<AnyType> {
return crazyFunction
.flatMap(functionThatCanErrorOut)
.flatMap(functionThatCanErrorOut)
.flatMap(functionThatCanErrorOut)
.flatMap(functionThatCanErrorOut)
.flatMap(functionThatCanErrorOut)
}
button.rx_tap
.flatMap(doManyThings)
.catchError { handleErrors($0) }
.subscribeNext { input in
// do something
}
Is it not possible to catch all the errors in a central place without doing subscribeError
which cancels the subscription entirely??? I now have the case that .catchError()
is called, no matter what error, but when I tap button
a second time, nothing happens because it seems the subscription is canceled.
How do you solve this kind of issue?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 21 (1 by maintainers)
Based on answer the solution is:
And it used like this
But I personally prefer:
This is used like this: