たとえば、5つの呼び出しがあり、それらを特定の順序で並行しないようにするために、5つのチェーン要求を行う必要があります。ここでretrofitとrxjavaのチェーン要求
私の観測のいくつかの例は、
Observable<ResponseBody> textsCall=EndpointFactory.provideEndpoint().getTexts(textsTask.getLanguage())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
Observable<AirportCombo> routesCall=EndpointFactory.provideEndpoint().getRoutes()
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread());
実は、私はRXのJava上でそれを何の機能かわからないされています。
以前のIVEは並列リクエストを実装しましたが、今はシリアルが必要です。
あなたがここに並列的なアプローチが必要な場合は、次のとおりです。
Observable<ResponseResult> combined = Observable.zip(textsCall, routesCall, (textsBody, airportCombo) -> {
//some parsing and other logic
return new ResponseResult(flag);
});
を機能をflatmap使用することができますが、通常、このようなチェーンの要求に 'flatMapを()'使用します。..とりわけ、第1の呼の結果が第2の呼を行うときに必要である場合。 –