I have the following service calls available:
productService.GetAllProducts()
productService.DeleteProduct()
productService.GetCategories()
productService.DeleteCategory()
In sudo code I need to do the following in my component:
Get a list of products using productService.GetAllProducts().
Loop through the list of products and call productService.DeleteProduct() for each product.
Once I can confirm the above deletes are all complete (due to db constraints) I need to then get a list of categories using productService.GetCategories(). Loop through each category and call productService.DeleteCategory().
I am aware that my life would be a lot easier if I had better backend calls to do bulk deletes, but I do not have a choice in this case. I need to follow the pattern of getting a list, looping through it, doing an individual delete one each item.
Is it even possible doing what I am trying to do using flatMap and the observable complete param? My biggest problem is knowing when the code is finished deleting all of the products before searching for and deleting all of the categories.