I need to do:
zip
is the way to combine observables
. Combining their results is just a consequence.
If you want to wait for both observables to finish (complete), the easiest way is to use zip
. You just don't have to use the results of your requests in the combining function. Just use this function as a way to emit something different when both of those calls finish. When this function emits an item:
[...] do something when all requests completed (show alert for example)
For example like this (executing someOtherCall
when both of those requests finish):
Observable obs1 = ...;
Observable obs2 = ...;
Observable.zip(obs1, obs2, new Func2() {
@Override
public String call(Integer integer, Long aLong) {
return "something completely different";
}
}).flatMap(new Func1>() {
@Override
public Observable call(String s) {
return performSomeOtherCall();
}
}).subscribe(...);