Skip to content

Instantly share code, notes, and snippets.

@roelofjan-elsinga
Created July 3, 2018 19:06
Show Gist options
  • Save roelofjan-elsinga/18fb24de08fa0ea933f7e26b943897e1 to your computer and use it in GitHub Desktop.
Save roelofjan-elsinga/18fb24de08fa0ea933f7e26b943897e1 to your computer and use it in GitHub Desktop.
Example languages reducer in Redux
import {ADD_LANGUAGE} from "../actions";
import {INITIAL_STATE} from "./initial-state";
import {ILanguage} from "../interfaces/languages";
export function languages(state = INITIAL_STATE.languages, action):ILanguage[] {
switch (action.type) {
case ADD_LANGUAGE:
return state.concat(Object.assign({}, action.language));
}
return state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment