Skip to content

Instantly share code, notes, and snippets.

@brandonroberts
Forked from alxhub/ngrx.ts
Created May 6, 2022 13:30
Show Gist options
  • Save brandonroberts/a38c5453263380a48e3caa229dbeb6ef to your computer and use it in GitHub Desktop.
Save brandonroberts/a38c5453263380a48e3caa229dbeb6ef to your computer and use it in GitHub Desktop.
ngrx add features example
function configureStoreWithFeature(feature: ...): Provider[] {
return [
{
provide: Store,
useFactory: () => {
const rootStore = inject(RootStore);
for (const feature of inject(STORE_FEATURE, [])) {
rootStore.registerFeature(feature);
}
return rootStore;
},
}, {
provide: STORE_FEATURE,
useValue: feature,
multi: true,
},
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment