Continuing from this previous post, I've decided to create a new post since the question in this one is different.
Query - How can I ensure that the forkJoin operation completes before executing other business logic?
Below is the Code Snippet
export interface indexLogic {
[id: number]: Detail;
}
async ngOnChanges(){
await getData();
// Need to guarantee that the following method only runs
// after this.indexLogic has been populated.
await useInformationReceivedFromgetData();
}
async getData(){
getInformations().subscribe(
informations => {
let subs = [];
for (const information of informations) {
subs.push(getOtherDetails(information.id).pipe(
map(data => ({ id: information.id, data })) // <---
));
}
this.indexLogic = [];
forkJoin(subs).subscribe(objects => {
objects.forEach(({id, data}) => { this.indexLogic.push({[id]:data}) });
});
}
);
}