I have the following service calls available:
productService.GetAllProducts()
productService.DeleteProduct()
productService.GetCategories()
prod
You may want to try something along these lines
productService.GetAllProducts()
.switchMap(
products => forkJoin(products.map(product => productService.DeleteProduct(product)))
)
.switchMap(() => productService.GetCategories())
.switchMap(
categories => forkJoin(categories.map(category => productService.DeleteCategory(category)))
)
.subscribe(() => console.log('done'))
The whole idea is the following
switchMap
map
, into an array of
Observables which are the result of DeleteProduct - the array of
Observable is passed to the first forkJoin
as its parameterforkJoin
emits when all the Observables it has received as
parameter complete, and therefore will emit when all the Products
have been deletedI am not sure the code is syntactically perfect, but it should be enough to give you an idea on how to proceed.