i am tying to understand how to use await in my situation.
i have this code:
updateMap() {
this.paramsTemp = 0;
if(this.updateMapCheck == true){
this.loading = true;
this.arrOfDisplays.forEach((display, index) => {
if (display.removed == true) {
if (this.locationsToSend[index + 1]) {
this.drawOneTrip(index, index + 1, index); // here after first one finish we go to another call, here i need await?
display.removed = false;
}
}
});
// after finish above i want to go to this.markerArr...
this.markersArr.forEach((marker, index) => {
marker.set("label", { text: "" + index, color: "white" });
});
// here most important, if above finish i want to call this.changeTime()
// wait to finish every think above to call changeTime()
this.changeTime();
// while every think finish in changeTime() i want to do last 2 line.
this.loading = false;
this.map.setZoom(14);
}
else{
this.showToasterErrorUpdateMap();
}
}
all information needed i put in code.
How to use await in above situation?
before i am using setTimeout for each step with time approximately, but not work perfectly because probably compiler go to another step before finish first step.