-
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
createStoreWith accepts either a function or an object with reducers #76
createStoreWith accepts either a function or an object with reducers #76
Conversation
Thanks Hugo, I'm really looking forward this |
import digestMiddleware from './digestMiddleware'; | ||
|
||
import assign from 'lodash.assign'; | ||
import isArray from 'lodash.isarray'; | ||
import isFunction from 'lodash.isfunction'; | ||
import isObejct from 'lodash.isobject'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a big typo here
@Fire-Dragon-DoL Fixed ;) |
Hi Hugo, thanks for looking into this! I went through your pull request and I'm wondering if this completely solves the problem of providing 1 reducer for Correct me if I'm wrong, but it seems that I must provide an Angular service that has the ability to provide all reducers for my application. In issue #75, I mention that, in order to not violate the single responsibility principle, I would like each module to be responsible for registering it's own reducers with ngRedux; in other words, Again, perhaps I'm just misunderstanding what you wrote, so thanks again for taking this on :) |
@jballands True, this PR adds "only" the part where you can inject reducers into the store, but we also carefully evaluated the following: You can't register the reducer in the reducer itself. This is simply not possible because if the reducer register itself, it means the reducer doesn't get injected anywhere, and so angular will never load it. Sure we can have somewhere an object I consider this pull request extremely useful because it will allow you to use reducers as services, which in turn allows you to use services in reducers. This will:
|
@jballands I was thinking that while this doesn't solve #75 , it's definitely a first step (groundbase) toward having a solution for your problem. I still don't see how you are going to face the never-injected problem in angular (which in turn will never load the reducer), but I guess we can work towards it |
@Fire-Dragon-DoL I agree, I think this pull request is a step in the right direction and is certainly very helpful! I just don't think it solves issue #75 exactly. :) |
@jballands yeah I agree. I wonder if @wbuchwalter has the chance to review the pull request |
Hey! |
@wbuchwalter sure! No problem, we are going to use this PR on a software used extensively by our customers, so if there are issues, we will notice that immediately, will let you know. Thanks a lot for taking time to merge this stuff ;) |
Hi,
This PR aims to solve this issue -> #75 but in a different manner. We've implemented a way to pass the reducer as a single Function or as an Object. This is extremely helpful because we can create the reducers as an angular services and initialize it in the .config.
The reducer object would accept a function or a string for its values. Using it as a string, we can later use $injector.get("myReducerAsService") and get it injected.
It'll work like this: