Last active
November 18, 2019 20:45
-
-
Save codeBelt/9d183e2be52885f65826042fc4f6c228 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
const dictionary = {}; | |
// Add keys to the dictionary | |
dictionary['REQUEST_SHOW_FINISHED'] = (state, payload) => { | |
return { | |
...state, | |
show: payload, | |
} | |
}; | |
dictionary['REQUEST_EPISODES_FINISHED'] = (state, payload) => { | |
return { | |
...state, | |
episodes: payload, | |
} | |
}; | |
dictionary['REQUEST_CAST_FINISHED'] = (state, payload) => { | |
return { | |
...state, | |
actors: payload, | |
} | |
}; | |
// Usage | |
const newState = dictionary[action.type](state, action.payload); // Warning: This will break if the action.type is not found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment