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

26 lines
929 B
TypeScript
Raw Normal View History

2017-06-29 12:54:02 -06:00
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";
2019-12-27 13:58:44 -07:00
import { ReduxAction, Reducers } from "./interfaces";
2017-06-29 12:54:02 -06:00
import { Session } from "../session";
2019-12-10 13:17:37 -07:00
import { resourceReducer as resources } from "../resources/reducer";
2017-06-30 10:07:30 -06:00
import { Everything } from "../interfaces";
import { Actions } from "../constants";
2017-06-29 12:54:02 -06:00
2019-12-27 13:58:44 -07:00
export const reducers: Reducers = combineReducers({
2017-06-29 12:54:02 -06:00
auth,
bot,
config,
draggable,
2019-12-27 13:58:44 -07:00
resources,
});
2019-12-10 13:17:37 -07:00
2017-06-29 12:54:02 -06:00
/** 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<{}>) {
2018-01-04 11:23:06 -07:00
(action.type === Actions.LOGOUT) && Session.clear();
return reducers(state, action);
}