0
我現在有這個方法,它工作得很好:RxJava2如何使用CONCAT()超過4個觀測
public static Observable<MyCustomObject> run(Service networkService) {
return Observable.concat(
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
})
);
}
這只是相同的可觀測一遍又一遍。如果我加入有另一個像這樣:
public static Observable<MyCustomObject> run(Service networkService) {
return Observable.concat(
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
}),
networkService.getThingOne().map(response -> {
Request request = response.raw().request();
MyCustomObject case = new MyCustomObject(request);
return case;
})
);
}
然後我得到下concat()
下return case
但只是在case
部分的紅線。
任何人有任何想法呢?
編輯:我將問題標題從「爲什麼不工作」更新爲「我如何得到這個工作」?我基本上有10個觀察對象,我想用concat()來保存,我可能會添加更多。所以我需要一些沒有限制的東西。
做Java的'concat'只允許4個信號源。 – GVillani82
@ GVillani82任何想法我可以做我的情況。我有大約10個觀測值我想串起來。 'getThingOne()'...'getThingTen()'。 – EGHDK
使用'concatArray'。 – akarnokd