When faced with the decision between promises, async awaits, and mapping operators like concatMap, how do you determine which one to use?
Specifically, I am working on a scenario where I need to make an http call to my backend, followed by another http call. The data from the second call relies on values returned by the first call. In this case, would it be more efficient to implement async await, a promise, or make use of concatMap? Furthermore, are there general guidelines for selecting the most appropriate method?
I currently have an implementation using concatMap wherein I dynamically generate child components based on the data retrieved from my getTask http call, ensuring each child component has access to annotationFormats.
this.dashboardService.getAnnotationFormats()
.pipe(
concatMap(annotationFormats=> this.dashboardService.getTasks())
)
.subscribe(
(tasks)=>{
for(let task of tasks){
const componentFactory=this.CFR.resolveComponentFactory(DashboardItemComponent);
const componentRef=this.vc.createComponent(componentFactory);
componentRef.instance.task=task;
componentRef.instance.annotationFormats=annotationFormats;
componentRef.instance.compInteraction=this;
this.taskRef.push(componentRef);
}
}
);