我需要约5个链接请求例如我有5个不同的调用,我想让他们串行不按特定顺序并行。链接请求与改造和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());
的一些例子其实,我不知道是什么功能做它的Java RX。
早先我实现了并行请求,现在我需要串行。
如果您在此处需要并行方法你:
Observable<ResponseResult> combined = Observable.zip(textsCall, routesCall, (textsBody, airportCombo) -> {
//some parsing and other logic
return new ResponseResult(flag);
});
通常会使用'flatMap()'来链请求这样的..特别是在打第二个电话时需要第一个电话的结果。 –