Skip to content

Instantly share code, notes, and snippets.

@arackaf
Created December 22, 2015 19:34
Show Gist options
  • Save arackaf/ac906cadfcfbe7eb5118 to your computer and use it in GitHub Desktop.
Save arackaf/ac906cadfcfbe7eb5118 to your computer and use it in GitHub Desktop.
function subjectsReducer(state = initialSubjectsState(), action = {}){
switch(action.type){
case LOAD_SUBJECTS_RESULTS:
return Object.assign({}, state, { list: subjectsToHash(action.subjects) });
}
return state;
}
function subjectsToHash(subjects){
let hash = {};
subjects.forEach(s => hash[s._id] = s);
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment