-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add overload support for StoreModule.forFeature({ name, reducer }) #2809
Comments
Just out of interest, are you using redux toolkit with NgRx @lacolaco ? |
@timdeschryver Recently I'm experimenting that interop and I feel it works well more than I expected. NgRx's Redux-compability (shape of actions and reducers) is great for integrate to Redux ecosystem. |
When I use Redux Toolkit with NgRx Store, the role of NgRx is just bridging Angular's dependency injection system and Redux state management. Redux Toolkit can help developers to create state management logic with (almost) zero boilerplates but it doesn't have a lazy-loading mechanism. I think NgRx store can be thinner by delegating Redux-things to the Toolkit. |
@lacolaco When I created it, I was not aware of |
Hey, just wanted to say that I love this idea! It's really neat to see interop back and forth between the Redux and NgRx ecosystems. We probably should have more interop than there is now, so it's great to see suggestions like this! |
@lacolaco seems reasonable to me to have some interop here. |
@markerikson Glad to see you're here. If this lands, would it make sense to have createSlice({
name: 'counter',
initialState: { count: 0 },
reducers: {
increment: state => state.count ++
}
})
|
I'm reallllly hesitant to do that, especially because our TS types are already stupidly complex, and more options are just going to make that more difficult to deal with. Also, part of the point of RTK is to be opinionated and just handle that stuff for you. If someone wants to take the time to figure out how that might be implemented and file a PR, I'm open to discussing it, but I'm going to need convincing this is a thing that is really worth adding to RTK. |
@brandonroberts Thanks. Does it mean could I start creating a PR? |
@lacolaco sure |
Proposal
I propose a new overload signature of
StoreModule.forFeature()
.Motivation
The interface
{name, reducer}
is compatible with theSlice
type from Redux Toolkit package.Redux Toolkit is a set of best practices for using Redux. I think it's better to have interoperability with that.
With Redux Toolkit, a typical small example will be like below:
A slice has its
name
andreducer
. Its concept is similar to NgRx's "feature". So I want to link them seamlessly. The following is an example whenforFeature()
supports{name, reducer}
option.Describe any alternatives/workarounds you're currently using
Other information:
If accepted, I would be willing to submit a PR for this feature
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: