从这个意义上说,我正在获得产品,并且如果该产品具有“ childProducts”,它将成为一系列产品。
然后,在map函数上,数组中每个产品都有一个弹出模式。
我想在完成所有产品的地图时采取一些措施。
如何实现?
@Effect()
selectProductPage$ = this.actions$.ofType<SelectProduct>(OrderActionTypes.SelectProduct).pipe(
map(action => action.payload),
switchMap((product) => {
const allTests = [product, ...(product.product.childProducts || [])].map(cloneDeep);
return from(allProducts);
}),
map((product: any) => {
// pop up modal for each product
})
);
您可以使用tap rxjs运算符在“映射”完成后执行一些操作。
所以您的代码将变得像
@Effect()
selectProductPage$ = this.actions$.ofType<SelectProduct>OrderActionTypes.SelectProduct).pipe(
map(action => action.payload),
switchMap((product) => {
const allTests = [product, ...(product.product.childProducts || [])].map(cloneDeep);
return from(allProducts);
}),
map((product: any) => {
// pop up modal for each product
}),
tap((result) => this.finishRequest(result)) // HERE IS THE CHANGE
);