Farmbot-Web-App/frontend/redux/root_reducer.ts

26 lines
929 B
TypeScript

import { authReducer as auth } from "../auth/reducer";
import { botReducer as bot } from "../devices/reducer";
import { configReducer as config } from "../config/reducer";
import { draggableReducer as draggable } from "../draggable/reducer";
import { combineReducers } from "redux";
import { ReduxAction, Reducers } from "./interfaces";
import { Session } from "../session";
import { resourceReducer as resources } from "../resources/reducer";
import { Everything } from "../interfaces";
import { Actions } from "../constants";
export const reducers: Reducers = combineReducers({
auth,
bot,
config,
draggable,
resources,
});
/** This is the topmost reducer in the application. If you need to preempt a
* "normal" reducer this is the place to do it */
export function rootReducer(state: Everything, action: ReduxAction<{}>) {
(action.type === Actions.LOGOUT) && Session.clear();
return reducers(state, action);
}