angular - NgRx 中的 reducer 增强器相当于什么?

标签 angular redux ngrx reducers

我正在尝试使用 @ngrx/store 在我的应用程序中实现撤消/重做功能。

这里描述了基本概念(Redux):https://redux.js.org/recipes/implementing-undo-history

在配方中的某个时刻,reducer 函数被包装在 Redux 中所谓的 reducer 增强器

A reducer enhancer (or a higher order reducer) is a function that takes a reducer, and returns a new reducer that is able to handle new actions, or to hold more state, delegating control to the inner reducer for the actions it doesn't understand.

NgRx 中与此等效的是什么?我如何构建商店...

store.pipe(select('counter')); 

...但是将其包装在“增强器”函数中?伪代码:

undoable(store.pipe(select('counter'));

有人向我指出了元 reducer ( https://ngrx.io/guide/store/metareducers ),但是相关文档并没有为我解决问题。

最佳答案

元 reducer 是这里的正确答案。它具有与 redux 文档相同的 API,它接收一个 reducer 并返回一个 reducer 。另一个示例可能是用户注销时刷新状态的用例。

enter image description here

关于angular - NgRx 中的 reducer 增强器相当于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54889699/

相关文章:

javascript - 删除 reducer 中的动态属性

Angular NgRx 选择器返回未定义

rxjs - 如何在 Angular 5 应用程序中使用 CLI 创建新的 @ngrx 文件?

angular - 如何在计时器触发后正确调用函数进行单元测试。 Angular 7,RXJS 6

angular - Angular2 中的单选按钮未按预期工作

angular - 依赖于其他效果结果的链式效果

javascript - Redux Form - 填充初始值

json - TypeScript 在对象数组上使用 forkJoin

reactjs - 使用react-redux触发事件操作

angular - 多个连续效果未完成?