Question -- how combine reducers in ember-redux?
See original GitHub issueI saw examples of combining reducers over in the redux.js.org docs. I was wondering how to go about this in Ember redux? For this example, I have a settings
and a users
reducer, that will manage those pieces of the state respectively, so the store’s state shape should be
{
settings: // settings data,
users: // users data
}
I tried bringing in redux and doing this with combineReducers
, but I got an error – here are my reducers:
// app/reducers/settings.js
const settings = (state, action) => {
// reducer code here
};
export default {
settings
}
// app/reducers/users.js
import { combineReducers } from 'redux';
import settings from './settings';
const users = (state, action) => {
// reducer code here
};
export default combineReducers({
settings,
users
})
It worked if I switched the exports for the two reducers to be as follows:
// settings.js
export default settings
// users.js
export default {
settings,
users
}
But I wasn’t sure if that does what it needs to. The redux docs show a longhand combineReducers
equivalent like this:
// users.js
function rootReducer(state = {}, action) {
return {
settings: settings(state.settings, action),
users: users(state.users, action)
};
}
export default rootReducer
But that didn’t work for me either.
What is the ember-redux
way to combine reducers together to compose a state tree?
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (4 by maintainers)
Top Results From Across the Web
combineReducers(reducers) - Redux
The combineReducers helper function turns an object whose values are different reducing functions into a single reducing function you can ...
Read more >JavaScript Guide - ember-redux
//app/reducers/index.js import { combineReducers } from 'redux'; import restaurants from './restaurants'; export default combineReducers({ restaurants });.
Read more >ember-cli-redux
Route.extend(EmberRedux, { reduxStore: Ember.inject.service(), ... Redux provides a helpful combineReducers function which simply chains ...
Read more >Redux without React — State Management in Vanilla JavaScript
The application in question is a mobile-first Tetris clone, ... import { createStore } from 'redux' import reducers from '.
Read more >How can I combine multiple combineReducers functions in ...
@user3409950 Please ask a separate question about Redux Form specifically. I don't quite understand the question. – Dan Abramov. May 25, 2016 at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@skitterm this is now up in the v2.5.0 release on npm
Let me know if anyone has issues/ or further questions about
combineReducers
specificallyThe store extensibility discussion will continue over in PR #121 for those interested
Yep, it works great.