Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattraykowski/73c1cc7e6dc7f67f7fed7925217f5615 to your computer and use it in GitHub Desktop.
Save mattraykowski/73c1cc7e6dc7f67f7fed7925217f5615 to your computer and use it in GitHub Desktop.
import { Record, List } from 'immutable';
const State = Record({
posts: List(),
collapsedComments: List(),
activeCategoryFilter: 'hot'
});
export default function(state = State(), action) {
switch(action.type){
case 'UPDATE_POSTS':
return state.set('posts', actions.posts);
case 'UPDATE_FILTERED_POSTS':
return state.set('filteredPosts', action.filteredPosts);
case 'UPDATE_ACTIVE_POST':
return state.set('activePost', action.activePost);
case 'UPDATE_POST_COMMENTS':
return state.set('postComments', action.postComments);
case 'TOGGLE_COLLAPSE':
return state.set('collapsedComments', action.collapsedComments);
case 'TOGGLE_DOMAIN_FILTER':
return state.set('activeDomainFilter', action.activeDomainFilter);
case 'TOGGLE_CATEGORY_FILTER':
return state.set('activeCategoryFilter', action.activeCategoryFilter);
default: return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment