My Angular 2 application has 2 methods (GetCategories()
and GetCartItems()
) in a service , and both of these methods return Observable
Looks like GetCartItems
doens't depend on GetCategories
. Then you can use zip:
Observable
.zip(
this.appService.GetCategories()
this.appService.GetCartItems()
)
.catch(err => this.toaster.error(err))
.subscribe(([categories, cartItems]) => {
this.appService.categories = categories;
this.appService.cart = cartItems;
});