-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
Make dependent reducer explanation more prominent #1653
Comments
Also I still think this shouldn’t be the default behavior for export default function todos(state = {}, action) {
return {
byId: byId(state.byId, action, state),
listedIds: listedIds(state.listedIds, action, state)
}
} or export default function todos(state = {}, action) {
var nextById = byId(state.byId, action, state.listedIds);
var nextListedIds = listedIds(state.listedIds, action, nextById);
return {
listedIds: nextListedIds,
byId: nextById
}
} or export default function todos(state = {}, action) {
var nextListedIds = listedIds(state.listedIds, action, state.byId);
var nextById = byId(state.byId, action, nextListedIds);
return {
listedIds: nextListedIds,
byId: nextById
}
} The order is up to you, depending on your needs. |
Writing a "Structuring Reducers" recipe page is still on my to-do list. Might have time to take a first crack at it this weekend. We'd then be able to add a link to it in the "sharing state" FAQ question. |
Some month ago I wrote a micro-module to perform this task and combine reducers specifying their dependencies, turned out that this is mostly a rare case. Turns out it's handy but using side-effects handling could achieve the same result. |
@mattiamanzati That’s a neat module 😄 . |
This is a pattern we don’t encourage to use all the time, but sometimes it’s handy.
We should really include it in the FAQ, or better, write a recipe.
https://twitter.com/dan_abramov/status/723157303340326913
The text was updated successfully, but these errors were encountered: