question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question -- how combine reducers in ember-redux?

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
toranbcommented, May 2, 2017

@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 specifically

The store extensibility discussion will continue over in PR #121 for those interested

1reaction
skittermcommented, May 1, 2017

@skitterm if you npm install the branch in PR #119 does it work as you expect allowing you to leverage combineReducers?

Yep, it works great.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found