In my ngOnInit, I would like to wait for all requests of fetchLists to finish before proceeding:
ngOnInit(): void {
this.fetchLists();
this.route.params.subscribe(params => {
this.doSomethingWithFetchedLists();
}
});
}
fetchLists(): void {
this.httpHandlerCached.getListsA()
.subscribe(listA => this.listA = listA);
this.httpHandlerCached.getListsB()
.subscribe(listB => this.listB = listB);
this.httpHandlerCached.getListsC()
.subscribe(listC => this.listC = listC);
}
Please hear me out, my previous question was closed with a reference to use "forkJoin": Wait for multiple promises to finish
However, with forkjoin I have the exact same issue:
fetchListnames() {
return forkJoin([
this.httpHandlerCached.getListsA(),
this.httpHandlerCached.getListsB(),
this.httpHandlerCached.getListsC(),
]).subscribe(res => {
this.listA = res[0];
this.listB = res[1];
this.listC = res[2];
});
}
So with the proposal to use forkJoin, how can I now wait for the forkjoin to finish before proceeding (meaning before this.doSomethingWithFetchedLists()
is called)?