1
我正在將rxjava 1升級到rxjava 2.在rxjava 1中有OnErrorThrowable,但在rxjava中找不到2.在下面的代碼中,我可以做什麼來替換OnErrorThrowable?在rxjava中找不到OnErrorThrowable 2
static Observable<String> sampleObservable() {
return Observable.defer(new Callable<ObservableSource<String>>() {
@Override
public ObservableSource<String> call() throws Exception {
try {
// Do some long running operation
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
} catch (InterruptedException e) {
throw OnErrorThrowable.from(e);
}
Log.d(TAG, "The sleep is over, now produce something");
return Observable.just("one", "two", "three", "four", "five");
}
});
}
嘿大衛,怎麼樣()像'onErrorReturn情況下',在那裏我們以前用'OnErrorThrowable.from()'重新拋出錯誤? – Saket