vendredi 27 février 2015

How to aggregate multiple JavaRX Observables



I have a list of Observables and I want to know when they have all completed. In particular I want to know if they all completed successfully or any one of them had an error. All observables in the list should be completed before the successful or error notification executes. I don't need any information about the results or errors in these notifications.


I tried the Observable.merge(list) but it stops with the first error.


Desired example



Observable.all(listOfObservables)
.onSuccess(() -> {}) // only called if all completed successfully
.onError(() -> {}) // only called after all completed and at least one errored
.onComplete(() -> {}; // called after all completed regardless of success or error


This seems like a standard behavior; other 'async promise' like frameworks support this. Does JavaRx support this behavior? What is the best approach to achieve this?




Aucun commentaire:

Enregistrer un commentaire