I'm trying to execute two Maybe
at once and call a specific method once both are done. This works if both Observables return a value but in certain cases one might not emit an item thus calling only doOnComplete
and not doOnSuccess
. So if one of those Maybes' doesn't call doOnSuccess
the zip()
block isn't executed. I'm wondering how to handle such a scenario?
Following my code (stripped down to the essential part):
private void fetchData(){
Maybe<Integer> maybeOne = getId(); // may return Maybe.empty()
Maybe<List<String>> maybeTwo = getList();
Maybe.zip(maybeOne, maybeTwo, (id, list) -> {
initView(id, list); // only called if values have been emitted
return true;
}).subscribe();
}
I would expect that the zip() block is always called but with null values in case the Maybe didn't call onSuccess
. This isn't the case so can I handle such a scenario?