Suppose we have 3 services, employeeTitle, employeeName, employeeLocation. If all services three services throw error employeeTitle, employeeName and employeeLocation will service only throw 1 error? According to the documentation this should be the behavior is this correct? What happens if only employeeTitle throws error and the other services are successful? As per my understanding if employeeTitle throws an exception then zip will still throw 1 exception only and this exception will be employeeTitle's service error. Am I in the right track?
-In my code below, I am expecting the zip error to come in the first onErrorResumeNext inside getEmployeeInfo()
Single<Model> getCompositeEmployeeInfo(){
return Single.zip(
api.employeeTitle()
.subscribeOn(Schedulers.newThread()),
api.employeeName()
.subscribeOn(Schedulers.newThread()),
api.employeeLocation()
.subscribeOn(Schedulers.newThread()),
new Function3<EmployeeTitle, EmployeeName, EmployeeLocation>() {
@public Model apply(EmployeeTitle empTitle, EmployeeName empName,
EmployeeLocation empLocation){
//some logic
}
Single<Model2> getEmployeeInfo(){
return getCompositeEmployeeInfo()
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(throwable-> {
return Single.error(throwable}//I am expecting only 1 error(if
//more than one error is thrown) from
//zip, either employeeTitle, employeeName or employeeLocation.
)
.flatMap(model -> {
//some logic
return getEmployeePreference();
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(throwable -> {
return Single.error(throwable);
})
.flatMap(employeePreference -> {
//some logic
return Single.just(result);
}); } }