0

我有一个ngrx v8样式化简器(使用 createReducer + on),它需要对路由更改做出反应。

let myAcction = createAction('my action', prop<boolean>);

let reducer = createReducer(
  initialState,
  on(myAction, (state, prop) => ({...state, example=prop })),
  on(ROUTER_NAVIGATION, (state, routeParams) => ({...state, example2:{...routeParams}}))
)

这无法编译,因为ROUTER_NAVIGATION不是动作创建者:

'"@ngrx/router-store/navigation"' 类型的参数不可分配给 'ActionCreator>' 类型的参数。类型“@ngrx/router-store/navigation”不可分配给类型“FunctionWithParametersType”

它不适用于RouterNavigationAction以下任何一种:

'boolean' 类型的参数不能分配给 'ActionCreator>' 类型的参数

如何在 createReducer/on 函数中使用 ngrx/router-store 操作?我找不到为给定动作导出的动作创建者。

4

1 回答 1

2

我会在他们的存储库上针对 ngrx 提出问题。同时,您可以通过在对象中使用令牌来绕过它:{ type: ROUTER_NAVIGATION }因为这就是它在引擎盖下的工作方式。这并不理想,但在他们修复它之前它可以工作。

于 2019-09-20T14:54:09.497 回答