MCPcopy Create free account
hub / github.com/ngrx/platform / initializeBaseEntityData

Function initializeBaseEntityData

modules/data/src/provide-entity-data.ts:88–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86];
87
88function initializeBaseEntityData(): void {
89 const reducerManager = inject(ReducerManager);
90 const entityCacheReducerFactory = inject(EntityCacheReducerFactory);
91 const entityCacheName = inject(ENTITY_CACHE_NAME_TOKEN, {
92 optional: true,
93 });
94 const initialStateOrFn = inject(INITIAL_ENTITY_CACHE_STATE, {
95 optional: true,
96 });
97 const metaReducersOrTokens = inject<
98 Array<MetaReducer<EntityCache> | InjectionToken<MetaReducer<EntityCache>>>
99 >(ENTITY_CACHE_META_REDUCERS, {
100 optional: true,
101 });
102
103 // Add the @ngrx/data feature to the Store's features
104 const key = entityCacheName || ENTITY_CACHE_NAME;
105 const metaReducers = (metaReducersOrTokens || []).map((mr) => {
106 return mr instanceof InjectionToken ? inject(mr) : mr;
107 });
108 const initialState =
109 typeof initialStateOrFn === 'function'
110 ? initialStateOrFn()
111 : initialStateOrFn;
112
113 const entityCacheFeature = {
114 key,
115 reducers: entityCacheReducerFactory.create(),
116 reducerFactory: combineReducers as ActionReducerFactory<EntityCache>,
117 initialState: initialState || {},
118 metaReducers: metaReducers,
119 };
120 reducerManager.addFeature(entityCacheFeature);
121}
122
123export const ENTITY_DATA_EFFECTS_PROVIDERS: Array<
124 Provider | EnvironmentProviders

Callers 1

Calls 3

mapMethod · 0.80
createMethod · 0.45
addFeatureMethod · 0.45

Tested by

no test coverage detected