-
Notifications
You must be signed in to change notification settings - Fork 177
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
Be able to register multiple reducers with ng-redux #75
Comments
Excellent point. |
I was facing the exact same problem, having reducers as constants (the only thing that can be injected during config) was definitely a problem, because it's quite common you want to use a service in reducer (think about an helper function), it also forces us to create a global object (not a constant) for the action types because is the only thing I can get within a constant (the reducers). If I find some time, would love to make a pull request |
@Fire-Dragon-DoL, I actually have a modified version of ngRedux with |
Hey, i wrote a new featute for this one #121 for being more precise, stay tuned to see if someone reivews the pull request! |
@Negan1911 functionality is already there and merged |
I have an application in which I split different pieces of functionality into Angular modules, and then use all the modules I need in a "core module" that actually bootstraps to the page:
All of these "feature modules" use ngRedux, so their
config
stages all resemble the following:The problem is:
createStoreWith
only allows a single reducer to be registered, meaning that you cannot register reducers from multiple "feature modules" with$ngReduxProvider
; in a example with 3 "feature modules", 2 will get smashed and only 1 will survive.It would be nice if
$ngReduxProvider
could register multiple reducers, and then the$get
method usescombineReducers
to combine all the registered reducers together and makes a store out of these combined reducers to create a single injectable instance of a$ngRedux
, thus preserving a single store. Usage may look like this:This allows each "feature module" to be responsible for its own reducers. Without this, the "core module" has to import all possible reducers, combine them, and then register them with
$ngReduxProvider
, breaking the single responsibility principle. Notice how each "feature module" should be able to register middleware with the$ngReduxProvider
.The text was updated successfully, but these errors were encountered: