0
我有一個異步調用,它完全調用一個getStatus()函數,對接收到的數據執行一些計算,然後返回計算的數據。我正在調用load()函數,並且我想要計算它的數據。JavaScript - 如何從訂閱中返回數據
load(case, start, end) {
Observable.forkJoin (
this.http.get('/workschedules'),
this.http.get('/block?startDate=' + start + '&endDate=' + end),
this.http.get('/filed?caseId=' + case+ '&startDate=' + start + '&endDate=' + end)
).subscribe(data => {
this.works$ = data[0];
this.block$ = data[1];
this.avail$ = data[2];
}, err => console.log(err),() => this.getStatus(case, 217380, start, end, 5));
}
getStatus(caseId, appId, start, end, capacity: number) {
//some calculation on all the subscribed data
return calculated_data;
}
我想load()函數調用的數據 例如。
let temp = load(12512,'22/10/2017','25/10/2017');
如何獲得異步調用計算的數據。 –
@ FarhanAnsari你通過'subscribe'收集它 – zurfyx