Skip to content

Instantly share code, notes, and snippets.

@wzup
Created May 26, 2017 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wzup/d390dc246c71dca7a1f70546a5843e4f to your computer and use it in GitHub Desktop.
Save wzup/d390dc246c71dca7a1f70546a5843e4f to your computer and use it in GitHub Desktop.
'use strict';
/**
* I make reducersFactory a function in order to pass it an initial state as a parameter.
* Switch-case are just for example. You may have your own
*/
function reducersFactory(initialState) {
return function reducers(state = initialState, action) {
switch (action.type) {
case 'login_success':
return Object.assign({}, state, {
user: action.user,
login_starts: false,
});
break;
case 'login_failure':
return Object.assign({}, state, {
user: action.user,
login_starts: false,
});
break;
default:
return state;
}
}
}
module.exports = reducersFactory;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment