【发布时间】:2018-06-12 16:12:33
【问题描述】:
我想进行两次调用,一次调用 github repos 列表,第二次调用每个 repo 上的提交,并希望将它们保存在一起。
在第二次调用中,我需要父 pojo 的实例,以便我可以将子响应添加到它。
即保存:Gitrepo
Gitrepo{
var name:String,
var commit:Commit //<-this is fetched in second call
}
当前代码:
networkModule.getRepos()
.flatMap { itemList ->
Observable.fromIterable(itemList)
}
.concatMapEager { item -> networkModule.getCommits(item.name!!)
.onErrorResumeNext(Observable.empty()) }
.subscribe(
{
//problem is here I get only Commit pojo,
//and have no access to Gitrepo, I'd like to do:
//gitrepo.commit = it
//db.save(gitrepo)
},
{
utilModule.logI("error response" + it.message)
}
)
【问题讨论】:
标签: android retrofit2 rx-java2 rx-android