-
-
Save ustun/a1b441d54894117e8b172065d14a849a to your computer and use it in GitHub Desktop.
todoappreducer8.js
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
function reducerFromRecordClass(klass) { | |
return function todoAppReducer(state=new klass(), action) { | |
var fn = state[camelcase(action.type)] | |
if (fn) { | |
return state[camelcase(action.payload)](action); | |
} else { | |
// we don’t recognize the method, return current state. | |
return state; | |
} | |
} | |
} | |
todoReducer = reducerFromRecordClass(Todo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment