簡體   English   中英

我的ngrx reducer只收到一個@ ngrx / store / init動作

[英]My ngrx reducer only receives a `@ngrx/store/init` action

我正在使用ngrx商店(以及路由器,路由器商店和效果模塊)開發電子商務Angular 6應用程序。

這是我第一次使用ngrx,到目前為止,一切都進行得很順利:我開發了幾個ngrx功能,每個功能都有各自的狀態和化簡,效果,模型和動作。

僅這次,我無法弄清楚自己做錯了什么。 對於我的最后一個功能,似乎沒有任何動作通過其減速器。 它捕獲的唯一動作是類型為'@ ngrx / store / init'的動作。

這是化簡器代碼:

 export function reducer(state = initialState, action: ItemCategoryActions): State { console.warn('item-category', action.type); switch (action.type) { case ItemCategoryActionTypes.LoadItemCategories: { return state; } case ItemCategoryActionTypes.LoadItemCategoriesComplete: { return { categories: (<LoadItemCategoriesComplete>action).payload.items}; } default: return state; } } 

我不會在這里重現我的所有代碼,因為它是您典型的ngrx樣板,但請向我保證,我已將reducer添加到根reducer映射中,已經導入了效果,並且已確保操作正確鍵入等。

運行我的代碼的日志跟蹤如下:

在此處輸入圖片說明

如您所見,捕獲@ ngrx / store / init動作的唯一減速器是我的新item-category減速器,它不捕獲任何其他動作。

我所有其他的減速器都按預期工作。

在這一點上,我已經用盡了所有假設,因此,有關如何調試此難題的任何線索將不勝感激。

找到了! 我的app.module有上次實驗的app.module

StoreModule.forFeature('itemCategory', fromItemLevel.reducer),

這顯然造成了混亂的混亂。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM