0
私はretrofitでObservableコールを持っていますが、3つのAPIコールを圧縮しました しかし、3つのコールをまとめたいのですが、いつか1つのコールが失敗します。私のために必須で、残りの呼び出しはオプションです。なぜなら、それらのうちの1つがエラーで失敗すると、それが欲しくないからです。もしJoinObservable.when(OperatorJoinPatterns.or(call1、call2))があれば私は考えていました。その後、 だけの事はあり、それはあなたのロジックを破るようメーリングリストでzipオペレータでObservableをオプションにする
Observable.zip(getSearchObservable(FIRST_PAGE), App.getApi().allbookmarks(), SpotlightUtil.getSpotLightBanner(), App.getApi().getFollowingSuggestions(AppConfigUtil.getFollowingSuggestions().getLimit()),
(searchResult, myFavouritesResults, spotlightListResult, followingSuggestionsResult) -> combineCall(searchResult, myFavouritesResults, spotlightListResult, followingSuggestionsResult, false))
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(spotlightsAndSearchResultAndSuggestionsResult -> {
//my main call that i want if that fail the request should fail
if (!NetUtils.isServerOk(spotlightsAndSearchResultAndSuggestionsResult.getSearchResult().getStatus())) {
throw new ServerErrorException(spotlightsAndSearchResultAndSuggestionsResult.getSearchResult().getErrorMessage());
}
if (spotlightsAndSearchResultAndSuggestionsResult.getSearchResult().posts.size() < PAGE_SIZE) {
rvPosts.setFinished(true);
}
hideLoader();
mPostAdapter.mSuggestions = spotlightsAndSearchResultAndSuggestionsResult.getFollowingSuggestionsResult().getSuggestion();
checkToAddOrRemoveFeedbackSpotLight(spotlightsAndSearchResultAndSuggestionsResult.getSearchResult().posts, true);
})
.doOnError(throwable -> {
ErrorScreenUtils.checkError(throwable, this, true);
hideLoader();
})
.retryWhen(RxActivity.RETRY_CONDITION).compose(bindUntilEvent(FragmentEvent.DESTROY))
.subscribe();
私のコードでは例として表示できますか? –