-
-
Save indigoviolet/a8f04996495fd6ef14a656769e720da4 to your computer and use it in GitHub Desktop.
fin blog embed
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
// adapted from http://redux.js.org/docs/advanced/AsyncActions.html#reducersjs | |
import { | |
REQUEST_POSTS, | |
RECEIVE_POSTS | |
} from '../actions' | |
function postsReducer( | |
state = { | |
isFetching: false, | |
items: [] | |
}, | |
action | |
) { | |
switch (action.type) { | |
case REQUEST_POSTS: | |
return Object.assign({}, state, { | |
isFetching: true, | |
didInvalidate: false | |
}) | |
case RECEIVE_POSTS: | |
return Object.assign({}, state, { | |
isFetching: false, | |
didInvalidate: false, | |
items: action.posts, | |
lastUpdated: action.receivedAt | |
}) | |
default: | |
return state | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment