Last active
April 17, 2019 09:01
-
-
Save MeetMartin/2789a476af780905b54f8102dcfc1c44 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// src/store/reducers.js | |
import match from 'conditional-expression'; | |
const initialState = { | |
something: 'data', | |
somethingElse: 'also data' | |
}; | |
const types = { | |
TRIGGER_ACTION: 'TRIGGER_ACTION' | |
}; // types could be in a separate file | |
const reducer = (state = initialState, action) => | |
match(action.type) | |
.equals(types.TRIGGER_ACTION) | |
.then({...state, something: action.payload}) | |
.equals(types.DIFFERENT_ACTION) | |
.then({...state, somethingElse: action.payload} | |
.else(state); | |
export {initialState, types, reducer}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment