WebStudio/src/store.ts

30 lines
864 B
TypeScript
Raw Normal View History

2019-11-26 10:01:26 +00:00
import rootReducer, { RootState } from "./rootReducer";
2020-03-19 22:24:00 +00:00
import { configureStore, Action, getDefaultMiddleware } from "@reduxjs/toolkit";
2019-11-26 10:01:26 +00:00
import { ThunkAction } from "redux-thunk";
import {
mixerMiddleware,
mixerKeyboardShortcutsMiddleware,
} from "./mixer/state";
import { tabSyncMiddleware } from "./optionsMenu/state";
2019-11-26 10:01:26 +00:00
const store = configureStore({
reducer: rootReducer,
middleware: [
mixerMiddleware,
mixerKeyboardShortcutsMiddleware,
tabSyncMiddleware,
...getDefaultMiddleware(),
],
2019-11-26 10:01:26 +00:00
});
if (process.env.NODE_ENV === "development" && module.hot) {
module.hot.accept("./rootReducer", () => {
const newRootReducer = require("./rootReducer").default;
store.replaceReducer(newRootReducer);
});
2019-11-26 10:01:26 +00:00
}
export type AppDispatch = typeof store.dispatch;
export type AppThunk = ThunkAction<void, RootState, null, Action<string>>;
export default store;