2019-07-08 20:27:38 +02:00

30 lines
617 B
JavaScript

/**
*
* listView reducer
*/
import { fromJS, List } from 'immutable';
import { GET_DATA_SUCCEEDED, RESET_PROPS } from './constants';
export const initialState = fromJS({
count: 0,
data: List([]),
isLoading: true,
});
function listViewReducer(state = initialState, action) {
switch (action.type) {
case GET_DATA_SUCCEEDED:
return state
.update('count', () => action.count)
.update('data', () => List(action.data))
.update('isLoading', () => false);
case RESET_PROPS:
return initialState;
default:
return state;
}
}
export default listViewReducer;