我是RxJava概念的新手。 我想链接一些电话:
Observable<RoomList> listRoomsCall = mRoomServiceApi.listRooms();
//这个电话会给我一个RoomIds 下一步是调用所有RoomIds - 请求后请求
mMeetingServiceApi.listMeetings(roomID, startsAtString, endsAtString, free))
我应该如何通过下次通话链接第一个电话?
我认为我应该使用flatMap
并循环来调用所有requets但是如何在最后连接所有响应?
listRoomsCall.flatMap(v -> {
for (ExchangeRoom exchangeRoom : v.getExchangeRoomList()) {
mMeetingServiceApi.listMeetings(roomID, startsAtString, endsAtString, free);
}
})
答案 0 :(得分:3)
将内部列表再次转换为task replaceTokens(type: Copy) {
from "${buildDir}/classes/main/WEB-INF/spring"
into "${buildDir}/classes/test"
filter(ReplaceTokens, tokens: [test: "${project.test}"])
}
和Observable
:
flatMap
或
listRoomsCall
.flatMapIterable(v -> v.getExchangeRoomList())
.flatMap(exchangeRoom -> {
mMeetingServiceApi.listMeetings(roomID, startsAtString, endsAtString, free);
})
.subscribe(/* */);