import { ReduxAction } from "@appsmith/constants/ReduxActionConstants"; import produce from "immer"; export const createReducer = ( initialState: any, handlers: { [type: string]: (state: any, action: any) => any }, ) => { return function reducer(state = initialState, action: ReduxAction) { if (handlers.hasOwnProperty(action.type)) { return handlers[action.type](state, action); } else { return state; } }; }; export const createImmerReducer = ( initialState: any, handlers: { [type: string]: any }, ) => { return function reducer(state = initialState, action: ReduxAction) { if (handlers.hasOwnProperty(action.type)) { return produce(handlers[action.type])(state, action); } else { return state; } }; };