簡體   English   中英

如何使用@ngrx/data 自定義我的減速器?

[英]How can I customize my reducers using @ngrx/data?

我正在學習使用@ngrx/data,確實使用那個庫我推進了很多代碼,但是在個性化它時我遇到了問題。 我已經看到如何將字段添加到 collections

export const entityMetadata: EntityMetadataMap = { User: { additionalCollectionState: { testing: null } } };

並在此處設置模塊:

export class UsersModule {
  constructor(private eds: EntityDefinitionService) {
    eds.registerMetadataMap(entityMetadata);
  }
}

那里一切都很好,但是......,我如何添加自己的減速器,在文檔中我看得不是很清楚

只需按照他們的文檔如何添加自定義減速器: https://ngrx.io/guide/data/entity-reducer#customizing-entity-reducer-behavior

您可以為實體類型創建自定義化簡器並直接使用EntityCollectionReducerRegistry.registerReducer()注冊它。

您可以通過調用EntityCollectionReducerRegistry.registerReducers(reducerMap)同時注冊多個自定義 reducer,其中 reducerMap 是一個 hash 的 reducer,以實體類型名稱為鍵。

也許這有幫助: https://slides.com/jiali/deck-5/fullscreen#/36

ngrx/data extension points
Change built in behaviors
Customized EntityCollectionService
Customized EntityAction/Dispatcher
Add property to EntityCollection
Customized DataService
Customized merge strategy
Customized http url generator
Customized plural names
Customized persistentResultHandler
Use normal ngrx
Dispatch own action
Add own reducer/effects

暫無
暫無

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

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