Rxjava链不止一个请求

时间:2017-12-18 12:27:01

标签: java android rx-java2

我是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);
            }
        })

1 个答案:

答案 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(/* */);