Как убрать подписку в подписке c помощью rxjs angular?
ngOnInit(): void {
this.sub.add(
this.orderService.getOrders().pipe(
map((orders: CreatedOrders[]) => {
return orders.map((order: CreatedOrders) => {
const price = [];
order.productItems.map((item: CartItem) => {
this.orderService.getCreatedCartItems(item).pipe(
map((itemData: ItemContent) => {
this.orderService.productPrice = Number((itemData.priceDto.price * item.quantity).toFixed(CONSTANTS.two));
price.push(this.orderService.productPrice);
if (price.length === order.productItems.length) {
this.orderService.methodSum(price)
}
return orders
})
).pipe(
mergeMap(orders => {
this.newOrdersData.next([])
for (let i = CONSTANTS.zero; i < orders.length; i++) {
this.newOrder = { ...orders[i], price: this.orderService.orderPrice[i] }
this.newOrdersData.next([...this.newOrdersData.value, this.newOrder]);
}
return this.newOrdersData
})
).subscribe()
})
})
}),
).subscribe()
)
}
Подскажите, как избавится от внутренней подписки (subscribe) с помощью rxjs?