So imagining i am iterating over a list of something, with Observable::from and for each item i want to perform a series of operations, which can return an error each one. Im doing it with flatMap, and at the end i return the original item, and call toList.
The chained observables that perform a couple of operations for each item can return an Error, and i want to, in all of those cases, to terminate the entire stream and just call the final onError, before the subscribe call.
Is there any way of accomplish that?
EDIT: I know i can use onErrorResumeNext and keep the Observable.from iterations going, but i want to terminate the stream, which means, no more iterations will be done if an error is found, and i just want to terminate the stream and display an error in the final OnError call. Code:
dbRepository.getAppAllHomeItems() .flatMap(Observable::from) .flatMap(homeItem -> knoxStandardSdk.wipeApplicationDataObs(homeItem.getApplicationPackageName())) .subscribeOn(Schedulers.computation()) .toList() .doOnError(throwable -> AppSnackbarUtils.showSnackBar((Activity)context, "Please Activate Licenses First!", AppSnackbarUtils.LENGTH_LONG)) .subscribe();