Вы можете попробовать вернуть Observable
из двух методов и объединить их в один:
private getAllData(event = null) {
merge(
this.methodOne(),
this.methodTwo()
).pipe(
finalize(() => {
if (event) {
event.target.complete();
}
}),
).subscribe();
}
private methodOne() {
return this.doGetRequest.get().pipe(tap(data => {
this._dataFromOne = data;
}));
}
private methodTwo() {
return this.doSomeGetRequest.get().pipe(tap(data => {
this._dataFromTwo = data;
}));
}
или без tap
(побочные эффекты вне подписки):
private getAllData(event = null) {
forkJoin(
this.methodOne(),
this.methodTwo()
).subscribe(([data1, data2]) => {
this._dataFromOne = data1;
this._dataFromTwo = data2;
}, err => {
//what do you do if one of them fails?
}, () => {
if (event) {
event.target.complete();
}
});
}
private methodOne() {
return this.doGetRequest.get1();
}
private methodTwo() {
return this.doSomeGetRequest.get2();
}