Created
February 28, 2018 10:45
-
-
Save rohanBagchi/74948e956b94560bb441a3d87ec0419e 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
| import { createAction } from 'redux-actions'; | |
| import keyMirror from 'keymirror'; | |
| export const default_state = { | |
| data: {}, | |
| ui: {} | |
| }; | |
| export const ArticleActionTypes = keyMirror({ | |
| SET_ARTICLES: null, | |
| }); | |
| export const setArticles = createAction( | |
| ArticleActionTypes.SET_ARTICLES, | |
| articles => ({ articles }) | |
| ); | |
| export default function reducer(state, action) { | |
| state = state || default_state; | |
| const { payload } = action; | |
| switch (action.type) { | |
| case ArticleActionTypes.SET_ARTICLES: | |
| return { | |
| ...state, | |
| data: { | |
| ...state.data, | |
| articles: payload.articles | |
| } | |
| }; | |
| default: | |
| return state; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment