Skip to content

Instantly share code, notes, and snippets.

@indigoviolet
Created October 4, 2017 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indigoviolet/dd4cbab7c39c293ed83d17bad8334f85 to your computer and use it in GitHub Desktop.
Save indigoviolet/dd4cbab7c39c293ed83d17bad8334f85 to your computer and use it in GitHub Desktop.
fin blog embed
function postsReducer(
state = {
isFetching: false,
data: [],
error: null,
},
action
) {
if (action.type === FETCH_POSTS) {
switch (action.readyState) {
case REQUEST:
return Object.assign({}, state, {
isFetching: true,
})
case SUCCESS:
return Object.assign({}, state, {
isFetching: false,
items: action.data.posts,
})
case FAILURE:
return Object.assign({}, state, {
isFetching: false,
error: action.error
})
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment