I am working on integrating a "next step" feature into my Angular 6 webapp. When the user clicks the "next step" button, the frontend triggers an action to update the database with the data in the store, another action to retrieve processed data from a Spring API, and finally, it progresses to the "next step".
My issue is that the inner dispatches are asynchronous, and the requests are processed in a random order, whereas they need to be in the correct order for the data to be accurate.
Below are my dispatches:
nextStep() {
this.tseProjectStore.dispatch(
new fromTSEProjectStore.UpdateProject(this.currentTSEProject, this.pathArchitecture, true, '')
);
this.tseProjectStore.dispatch(
new fromTSEProjectStore.SetSolution(this.currentTSEProject, this.pathInitSolution)
);
this.router.navigate(['adjustments-step', this.currentTSEProject.id], {relativeTo: this.route.parent.parent});
}
Is there a way to make the code wait for these dispatches to resolve before continuing execution?