在链 obs1.flatmap(x -> obs2()).subscribe(sub)
如果 obs2
产生错误,它会立即调用 onError
在 sub
上。这是记录在案的:
Note that if any of the individual Observables mapped to the items from the source Observable by flatMap aborts by invoking onError, the Observable produced by flatMap will itself immediately abort and invoke onError.
但是是否可以忽略 obs2
错误并使 obs1
继续发射?
最佳答案
Rx 提供了一些操作符来处理错误。只需从 obs2 创建第三个 Observable,它不会传播错误。
Observable<YourType> obs3 = obs2.onErrorResumeNext(Observable.<YourType>empty());
obs1.flatmap(x -> obs3)
关于java - RxJava 平面图 : How to skip errors?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42161293/