Skip to content

Instantly share code, notes, and snippets.

@argodeep
Created June 26, 2020 15:21
Show Gist options
  • Save argodeep/55ffad4bf7a46b4ee6833791bebf7456 to your computer and use it in GitHub Desktop.
Save argodeep/55ffad4bf7a46b4ee6833791bebf7456 to your computer and use it in GitHub Desktop.
Redux Reducers
import { ActionModel } from "../../models/action";
export function contacts (state = [], action: ActionModel) {
switch (action.type) {
case "GET_CONTACTS":
return action.data
default:
return state;
}
}
import { combineReducers } from 'redux';
import { contacts } from './api';
import { isSorted } from './sort';
const allReducers = combineReducers({
contacts, isSorted
});
export default allReducers;
import { ActionModel } from "../../models/action";
export function isSorted(state = false, action: ActionModel) {
switch (action.type) {
case "IS_SORTED":
return action.data
default:
return state;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment