I am doing a bit of a cascade delete with multiple service calls. Some of the later subscriptions rely on previous subscriptions to finish. How can I guarantee an subscription finishes before moving onto my next code?
// Need to make sure this code completes
data.forEach(element => {
this.myService.delete(element.id).subscribe();
});
// Before running this code
this.myService.getAll().subscribe(res => {
res.data.forEach(element => {
this.myService.delete(element.id).subscribe();
});
}
);
See Question&Answers more detail:os