ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
8.01k stars 1.97k forks source link

@ngrx/data missing forFeature method for lazy loading #2732

Closed wizardnet972 closed 3 years ago

wizardnet972 commented 3 years ago

I starting to use @ngrx/data.

according to docs I need to import EntityDataModule.forRoot(entityConfig) in the app.module file to make it work.

but my projects is divide by domain-packages. like: products, reports, companies.. (each of them, loaded during lazy loading). also each of them has StoreModule.forFeature(..).

since EntityDataModule has only forRoot, it force me to import the modules not in lazy loading way.

Is there any workaround solution here?

timdeschryver commented 3 years ago

We have documented this under https://ngrx.io/guide/data/entity-metadata#register-metadata

@NgModule({...})
class LazyModule {
  constructor(eds: EntityDefinitionService) {
    eds.registerMetadataMap(this.lazyMetadataMap);
  }
  ...
}