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