Comments (5)
A reducer needs to be a function - but you're passing in an object.
http://redux.js.org/docs/basics/Reducers.html
from redux-immutable.
Hey @pukapukan, Thanks for the answer, but still something is not quite clear to me..
redux-immutable supposed to work with canonical reducer composition right?
in the example given in redux docs there is no use of it,
in the CNC examples: https://github.com/gajus/canonical-reducer-composition
they also passing an object to redux-immutable's combineReducers helper:
reducer = {
countries: {
ADD_COUNTRY: (domain, action) {
return domain.push(action.country);
},
REMOVE_COUNTRY: (domain, action) {
return domain.delete(domain.indexOf(action.country));
}
},
cities: {
// Using a constructor.
CONSTRUCT () {
return [
'Rome',
'Tokyo',
'Berlin'
];
},
ADD_CITY (domain, action) {
return domain.push(action.city);
},
REMOVE_CITY (domain, action) {
return domain.delete(domain.indexOf(action.city));
}
},
// Implement a sub-domain reducer map.
user: {
names: {
ADD_NAME (domain, action) {
return domain.push(action.name);
},
REMOVE_NAME (domain, action) {
return domain.delete(domain.indexOf(action.name));
}
}
}
};
reducer = combineReducers(reducer);
I'm a little confused.
from redux-immutable.
No. You are talking about redux-immutable v1.
On Mar 8, 2016, at 08:32, Daniel Aviv [email protected] wrote:
Hey @pukapukan, Thanks for the answer, but still something is not quite clear to me..
redux-immutable supposed to work with canonical reducer composition right?
in the example given in redux docs there is no use of it,in the CNC examples:
they also passing an object to redux-immutable's combineReducers helper:`reducer = {
countries: {
ADD_COUNTRY: (domain, action) {
return domain.push(action.country);
},
REMOVE_COUNTRY: (domain, action) {
return domain.delete(domain.indexOf(action.country));
}
},
cities: {
// Using a constructor.
CONSTRUCT () {
return [
'Rome',
'Tokyo',
'Berlin'
];
},
ADD_CITY (domain, action) {
return domain.push(action.city);
},
REMOVE_CITY (domain, action) {
return domain.delete(domain.indexOf(action.city));
}
},
// Implement a sub-domain reducer map.
user: {
names: {
ADD_NAME (domain, action) {
return domain.push(action.name);
},
REMOVE_NAME (domain, action) {
return domain.delete(domain.indexOf(action.name));
}
}
}
};reducer = combineReducers(reducer);`
I'm a little confused.
—
Reply to this email directly or view it on GitHub.
from redux-immutable.
Got it @gajus,
Thanks for the quick response,
When i use a regular reducer function, I get the state argument as a plain JavaScript object rather than Immutable.js instance.
Is this the default behavior? if so.. what are the benefits of using redux-immutable? and how to use it properly?
What are the best practices of writing complex reducers and use immutable.js instance as a state?
Do you have any up to date implementation examples? (Including complex reducers with domains and nested domains, actions, etc..)?
from redux-immutable.
@DanielAviv1 you will need to open a separate question (assuming one does not exist) for each of those questions.
from redux-immutable.
Related Issues (20)
- React-router-redux selector documentation issue HOT 3
- Update from 3.0.9 to 3.0.10 causes flow-runtime errors HOT 1
- Link in README to combineReducers documentation is broken HOT 3
- Import state from redux-devtools not work HOT 4
- combineReducers not imported HOT 3
- Reducer is not a function (within state tree) HOT 1
- Add build option for es modules HOT 11
- State is undefined, can not get initial state HOT 2
- Trying to make it work with redux-auth
- Why can't I use Immutable.Record as initialState in rootReducer? HOT 6
- Changelog ? HOT 1
- please offer a browser built version HOT 6
- How to add non immutable store when combining reducers HOT 14
- bump dependancy to rc9 HOT 1
- Wrong return type of combineReducers HOT 10
- inputState.withMutations is not a function HOT 2
- Is this repo still maintained? HOT 2
- how to use redux hooks with redux-immutable? HOT 1
- Think I am seeing this too on IE11. This error HOT 1
- NPM release with the latest changes?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redux-immutable.