30 lines
617 B
JavaScript
Raw Normal View History

2019-07-08 17:01:12 +02:00
/**
*
* listView reducer
*/
2019-07-08 20:27:38 +02:00
import { fromJS, List } from 'immutable';
import { GET_DATA_SUCCEEDED, RESET_PROPS } from './constants';
2019-07-08 17:01:12 +02:00
2019-07-08 20:27:38 +02:00
export const initialState = fromJS({
count: 0,
data: List([]),
isLoading: true,
});
2019-07-08 17:01:12 +02:00
function listViewReducer(state = initialState, action) {
switch (action.type) {
2019-07-08 20:27:38 +02:00
case GET_DATA_SUCCEEDED:
return state
.update('count', () => action.count)
.update('data', () => List(action.data))
.update('isLoading', () => false);
case RESET_PROPS:
return initialState;
2019-07-08 17:01:12 +02:00
default:
return state;
}
}
export default listViewReducer;