0
更新數據我有一種情況,我需要:角及RxJS5 - 從http:插座
- 獲取路線PARAMS
- 使用路線PARAMS調用http服務
- 一旦HTTP響應,使用相同的路線PARAMS調用Socket服務
- 每次插座響應,從HTTP服務更新數據
理想我想保持這個我一個流。
如果只有我可以使用CombineLatest
?或涉及Scan
運營商?
this.data$ = this.route.params
.switchMap(params => {
return Observable.forkJoin([
Observable.of(params),
this.http.get('api', { prop1: params.prop1, prop2: params.prop2 })
])
}).combineLatest(([params, data]) => {
this.socket.get('event', { prop1: params.prop1, prop2: params.prop2 }),
updateData
})
private updateData(data, socketData): any[] {
//only returns data = [params, data]
//socketData always undef
return data;
}
我沒有意識到,嵌套的運營商合法嗎?我的印象是會造成問題,但似乎沒有。謝謝 – Thibs