UNPKG

@sheenarbw/redux-drf-sagas

Version:

If you are running Django Rest Framework on your backend then you can use these tools to get your js frontend to play nice with your backend. It's framework agnostic. It doesn't mean you would need to use redux as your main state management tool

26 lines (20 loc) 586 B
import types from "./types"; const INITIAL_STATE = {}; const reducer = (state = INITIAL_STATE, action) => { switch (action.type) { case types.ADD_API_ENTITIES_RESPONSE_TO_STORE: // entitiesObject, entityType; // responseIsList // responseEntityType const allInstances = state[action.entityType] ? { ...state[action.entityType], ...action.entitiesObject } : action.entitiesObject; return { ...state, [action.entityType]: allInstances, }; default: return state; } }; export default reducer;