Created
May 26, 2017 10:06
-
-
Save wzup/d390dc246c71dca7a1f70546a5843e4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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