簡體   English   中英

多次調用 ngrx/store-update-reducers

[英]ngrx/store-update-reducers called multiple times

這是我的代碼結構:

應用程序/
├──核心/
│ └── app.reducers.ts/
├── app.component.html
├── app.component.ts
├── app.module.ts
├── app-routing.module.ts
├──核心/
│ ├──頁腳/
│ ├── 標題/
│ ├── core.module.ts
├── 授權/
│ ├── 登錄/
│ ├── 注冊/
│ ├── store/
│ │ ├── auth.actions.ts
│ │ ├── auth.effects.ts
│ │ ├── auth.reducers.ts
│ ├── auth.module.ts
│ └── 服務/
├── 管理員/
│ ├──儀表盤/
│ ├──設置/
│ ├── store/
│ │ ├── admin.actions.ts
│ │ ├── admin.effects.ts
│ │ ├── admin.reducers.ts
│ ├── admin-routing.module.ts
│ ├── admin.module.ts
│ └── 服務/
└── 分享/
├── shared.module.ts
├──組件/
├──模型/
├──組件/
├── 指令/
└── 服務/

使用上面的代碼,我用多個模塊構建了我的代碼,並使用了@ngrx/store 庫。對於每個模塊,我有一個存儲(包括:action、reducer、effect)。 我在根目錄有一個主存儲,用於管理所有使用 metareducer(從 app.module.ts 導入)的存儲。 我正在使用 logger 查看每個調用的操作或更改的狀態,然后 logger 將在控制台日志中顯示當前狀態或操作。

當應用程序啟動時,來自瀏覽器的控制台日志多次顯示它們被商店調用。

我不知道為什么多次調用 store 中的 update-reducers。

我預計每個模塊的日志消息只會在模塊初始化時顯示一次。 我從許多將所有減速器存儲在一個地方的源代碼中進行了調查。 它對我的結構有好處嗎?

有人可以幫助我嗎?

作為記錄:這已在GitHub 上得到回答:

每個注冊減速器的新 StoreModule.forFeature 都會調用它。 這已在下一個主要版本中進行了更新,以將注冊的模塊組合到一個更新調用中。

暫無
暫無

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

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