-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added support for createStore to accept a reducer function #12
base: master
Are you sure you want to change the base?
Added support for createStore to accept a reducer function #12
Conversation
I could be wrong, but I think there is an easier way to do this. Reducers can be chained. If the reducer passed in is a function, we can just use logic something like this: // (initialReducer = {}, ...args) =>
const combinedReducer = combineReducers(reducers)
const overallReducer = (state, action) => initialReducer(combinedReducer(state, action), action)
store.replaceReducer(overallReducer) |
This should work with a regular reducer function. However, if the |
Interesting. I didn't know about UnexpectedStateShapeWarning. It's unfortunate to have to end-run a false warning message with some fairly runtime heavy code. Looking at your overall implementation, I'm concerned about the performance of the rootReducers. They do a lot of work every time an action is dispatched that could be cached. The actual work in the rootReducer should be as light as possible. Example: // these never change, but currently they will be executed for every dispatched action
const initialSlices = initialReducer ? initialReducer({}, '') : {}
const initialKeys = Object.keys(initialSlices)
const knownKeys = Object.keys(reducers) Are there any other opportunities to move any |
No description provided.