-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
49 lines (44 loc) · 1.51 KB
/
index.ts
File metadata and controls
49 lines (44 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { createBrowserHistory, History } from "history";
import {
AnyAction,
applyMiddleware,
combineReducers,
createStore,
} from "redux";
import {
connectRouter,
routerMiddleware,
RouterAction,
} from "connected-react-router";
import { AppActions, appReducer } from "./app";
import { FilesActions, filesReducer } from "./files";
import { editorReducer, EditorActions } from "./editor";
import { userReducer, UserActions } from "./user";
import thunk, { ThunkDispatch } from "redux-thunk";
import { composeWithDevTools } from "redux-devtools-extension";
import { useDispatch as _useDispatch } from "react-redux";
const createRootReducer = (history: History) =>
combineReducers({
router: connectRouter(history),
appReducer,
filesReducer,
editorReducer,
userReducer
});
export const history = createBrowserHistory();
const composeEnhancers = composeWithDevTools({ trace: true, traceLimit: 25 })
export const store = createStore(
createRootReducer(history),
composeEnhancers(applyMiddleware(routerMiddleware(history), thunk))
);
export type RootState = ReturnType<typeof store.getState>;
export type RootActions = AppActions | RouterAction | FilesActions | EditorActions | UserActions;
export type RootDispatch = ThunkDispatch<any, any, RootActions | AnyAction>;
// export type RootDispatch = AppDispatchTypes | RouterAction | FilesDispatchTypes;
export function useAppDispatch(): (event: RootActions) => void {
const dispatch = _useDispatch();
return (event: RootActions) => {
dispatch(event);
};
}
export default store;