Skip to content

Instantly share code, notes, and snippets.

@kazagkazag
Last active July 8, 2016 10:27
Show Gist options
  • Select an option

  • Save kazagkazag/e095fcd8bb71880b4827ac24d3d55634 to your computer and use it in GitHub Desktop.

Select an option

Save kazagkazag/e095fcd8bb71880b4827ac24d3d55634 to your computer and use it in GitHub Desktop.
/*
expected state:
{
accounts: {
items: []
isFetching: boolean
fetchingErrorMessage: string
}
}
*/
// accountReducers.js
function accounts() {}
function isFetching() {}
function fetchingErrorMessage() {}
export default combineReducers({
items: accounts,
isFetching,
fetchingErrorMessage
});
//combineReducers is from react-redux library, result is the same as here:
export default function (state = {}, action) {
return {
items: accounts(state.accounts.items, action),
isFetching: isFetching(state.accounts.isFetching, action),
fetchingErrorMessage: fetchingErroMessage(state.accounts.fetchingErrorMessage, action)
};
}
// rootReducer.js
// import accountReducers from "accountReducers.js"
export default combineReducers({
accounts: accountReducers
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment