I would like to create an Observable based on the following scenario:
Thanks.
You can make it work this way -
makeServerRequest()
.subscribeOn(Schedulers.io())
.map(someResponse -> {
if(saveTocache()) {
return someResponse;
} else {
throw new RuntimeException("Error while saving to cache");
}
})
.observeOn(AndroidSchedulers.io())
.subscribeWith(new Observer<SomeResponse> (){
public void onError(Throwable error) {
// here you will receive the runtime exception you throw.
}
:
:
:
});