You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
694 B

  1. import { TRENDS_FETCH_REQUEST, TRENDS_FETCH_SUCCESS, TRENDS_FETCH_FAIL } from '../actions/trends';
  2. import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
  3. const initialState = ImmutableMap({
  4. items: ImmutableList(),
  5. isLoading: false,
  6. });
  7. export default function trendsReducer(state = initialState, action) {
  8. switch(action.type) {
  9. case TRENDS_FETCH_REQUEST:
  10. return state.set('isLoading', true);
  11. case TRENDS_FETCH_SUCCESS:
  12. return state.withMutations(map => {
  13. map.set('items', fromJS(action.trends));
  14. map.set('isLoading', false);
  15. });
  16. case TRENDS_FETCH_FAIL:
  17. return state.set('isLoading', false);
  18. default:
  19. return state;
  20. }
  21. };