Created
December 4, 2017 16:06
-
-
Save MicroBenz/a9c1b39985f30a8205299328bf7d02d8 to your computer and use it in GitHub Desktop.
YWC15
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
// Actions | |
const LOAD = 'my-app/widgets/LOAD'; | |
const CREATE = 'my-app/widgets/CREATE'; | |
const UPDATE = 'my-app/widgets/UPDATE'; | |
const REMOVE = 'my-app/widgets/REMOVE'; | |
// Reducer | |
export default function reducer(state = {}, action = {}) { | |
switch (action.type) { | |
// do reducer stuff | |
default: return state; | |
} | |
} | |
// Action Creators | |
export function loadWidgets() { | |
return { type: LOAD }; | |
} | |
export function createWidget(widget) { | |
return { type: CREATE, widget }; | |
} | |
export function updateWidget(widget) { | |
return { type: UPDATE, widget }; | |
} | |
export function removeWidget(widget) { | |
return { type: REMOVE, widget }; | |
} | |
// side effects, only as applicable | |
// e.g. thunks, epics, etc | |
export function getWidget () { | |
return dispatch => get('/widget').then(widget => dispatch(updateWidget(widget))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment