0
我的方法有些疑问。我有两个类型观测值:rxswift:如何获得Observable <Any>导致Observable <[Category]>的组合?
//I can fetch from the server the houses and save them in the database
func houses() -> Observable<[House]>
//Given a houseId, I can fetch it's details and save them in the database
func houseDetail(id: Int) -> Observable<Family>
我想这样做可观察到其第一获取所有的房屋,然后获取家庭。我所做的是类似的东西:
//I am an observable which, when I complete, all data are saved
func fetchAllHousesAndFamily() -> Observable<Any> {
var allHousesObservables: [Observable] = []
for house in houses {
allHousesObservables.append(houseDetail(house.id))
}
return Observable.combineLatest(allHousesObservables)
}
但这似乎对......不为反应风格我,这似乎是一个黑客,因为我不知道有足够的了解RX运营商。
你有没有在rxworld中做到这一点的正确方法?
谢谢
我认为,你的任务有一个更优雅的解决方案。你可以在Github上分享你的任务代码吗?我想帮你。 – Svyatoslav