Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store: Introduce Standalone API for NgRx Store #3526

Closed
1 of 2 tasks
brandonroberts opened this issue Aug 12, 2022 · 1 comment · Fixed by #3539
Closed
1 of 2 tasks

Store: Introduce Standalone API for NgRx Store #3526

brandonroberts opened this issue Aug 12, 2022 · 1 comment · Fixed by #3539
Assignees

Comments

@brandonroberts
Copy link
Member

brandonroberts commented Aug 12, 2022

Information

Introduce standalone APIs for registering the Store and pieces of state for the @ngrx/store package. This should allow developers to use Store in a "module-free" application.

Based on the discussion in #3399 we are looking at adding two new functions

provideStore(reducerMap, rootConfig) - Registers the root-level providers for the global Store, and initial setup
provideState(reducerMap, featureConfig) - Registers additional features in the global Store

Also under consideration of whether we should separate the runtime checks from the provideStore() function so they can be tree-shaken in production builds

providers: [
  provideStore(),
  provideRuntimeChecks(config)
]

Related discussion: #3399

Describe any alternatives/workarounds you're currently using

Using importProvidersFrom function:

// main.ts
bootstrapApplication(AppComponent, {
  providers: [importProvidersFrom(StoreModule.forRoot({}))]
});

// feature.routes.ts:
export const featureRoutes: Route[] = [
  {
    path: '',
    component: FeatureComponent,
    providers: [importProvidersFrom(StoreModule.forFeature('name', reducer))],
  },
];

I would be willing to submit a PR to fix this issue

  • Yes
  • No
@yharaskrik
Copy link
Contributor

@brandonroberts did you start this? 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants