[英]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.