angular - 如何将两个ngrx动作减速器组合成一个角度?
问题描述
以下是单个操作的 reducer 代码。
on(apiContentActions.deleteApiContentsSuccess, (state, action) => {
return {
...state,
success: true,
};
}),
on(apiContentActions.deleteApiContentSuccess, (state, action) =>
adapter.updateOne(
{
id: action.apiContent.contentId,
changes: { ...action.apiContent, text: 'deleted' },
},
state,
)
),
我如何将它们组合成一个片段,而不是单独编写?
像这样的东西:
on(apiContentActions.deleteApiContentsSuccess, (state, action) => {
return adapter.updateOne(
{
id: action.apiContent.itemId,
changes: { ...action.apiContent, text: 'deleted' },
},
state,
)
&&
{
...state,
success: true,
};
}),
没有其他的。只是将减速器功能组合到一个主体中>=
解决方案
推荐阅读
- linux - 无法通过 SSH 连接到 Oracle 云实例
- excel - 如何使用 VBA 更改 PPT 中的图表
- python - Python:组合集合和数组
- python - Pandas DataFrame 从另一个 DataFrame 中找到最常见的字符串
- google-bigquery - GA4 事件实时显示,但不在参与/事件中
- html - 如何使用 Bootstrap 更改响应页面上的文本位置?
- html - AllegroServe 的 htmlgen 中的 form、img、span 和 table 标签有什么特别之处?
- arrays - Google sheets - eliminating common elements from two ranges
- postgresql - 具有可分页结果的 JPA 查询引发异常(说它应该是不可分页的)
- xcode - 为什么我在 UItextfields 中写的内容在几秒钟后或每当用户按 Enter 时都会消失?