stream-saga/src/js/reducers/index.js

25 lines
530 B
JavaScript
Raw Normal View History

2019-06-19 16:37:03 -04:00
import { ADD_ARTICLE } from '../constants/action-types'
2019-06-19 14:24:21 -04:00
const initialState = {
2019-06-19 17:08:53 -04:00
articles: [],
remoteArticles: []
2019-06-19 14:24:21 -04:00
}
function rootReducer(state = initialState, action) {
if (action.type === ADD_ARTICLE) {
return Object.assign({}, state, {
articles: state.articles.concat(action.payload)
})
}
2019-06-19 17:08:53 -04:00
else if (action.type === "DATA_LOADED") {
return Object.assign({}, state, {
2019-06-21 00:06:42 -04:00
remoteArticles: state.remoteArticles.concat(action.payload.message.statuses)
2019-06-19 17:08:53 -04:00
})
}
2019-06-19 14:24:21 -04:00
return state
}
export default rootReducer