[英]Using @ngrx/router-store actions with ngrx 8 createReducer() and on() function
我有一个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 操作? 我找不到为给定动作导出的动作创建者。
我会在他们的存储库上针对 ngrx 提出问题。 同时,您可以通过使用 object: { type: ROUTER_NAVIGATION }
中的令牌来绕过它,因为这就是它的工作原理。 这并不理想,但在他们修复它之前它可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.