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

feat(store): add object-style StoreModule.forFeature overload #2821

Merged
merged 2 commits into from
Dec 16, 2020

Conversation

lacolaco
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #2809

What is the new behavior?

Adding a new overload for StoreModule.forFeature();

  static forFeature<T, V extends Action = Action>(
    slice: FeatureSlice<T, V>,
    config?: StoreConfig<T, V> | InjectionToken<StoreConfig<T, V>>
  ): ModuleWithProviders<StoreFeatureModule>;

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

I think my code is not elegant because added overload has a very different shape. I'd like to be commented on codes.

@@ -216,4 +216,34 @@ describe(`Store Modules`, () => {
});
});
});

describe(`: Slice-Like paramter`, () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be tested with the real RTK slice as an integration spec?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that that is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, perhaps we could add a recipe to use NgRx with RTK in the future, as a separate PR.

@ngrxbot
Copy link
Collaborator

ngrxbot commented Dec 11, 2020

Preview docs changes for 2703c2d at https://previews.ngrx.io/pr2821-2703c2d9/

@brandonroberts brandonroberts merged commit 17571e5 into ngrx:master Dec 16, 2020
@brandonroberts
Copy link
Member

Thanks @lacolaco!

@alex-okrushko
Copy link
Member

@lacolaco @brandonroberts

we'd need to rollback this PR, it's breaking g3 - and any codebase that is still using ViewEngine (the cause itself is my guess).

This is what I have:

error TS100: Error during template compile of 'StoreModule'
  Function calls are not supported in decorators but 'StoreModule' was called.

@alex-okrushko
Copy link
Member

@lacolaco Would you be able to take a look at it?
The potential solutions are fairly well described here: https://medium.com/angular-in-depth/solving-aot-error-in-ngrx-function-calls-are-not-supported-in-decorators-5c337381457a

brandonroberts added a commit that referenced this pull request Jan 17, 2021
…#2885)

* feat(store): add object-style StoreModule.forFeature overload (#2821)

Closes #2809

* fix(store): update StoreModule to be compliant with AOT

Co-authored-by: Suguru Inatomi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add overload support for StoreModule.forFeature({ name, reducer })
5 participants