-
Notifications
You must be signed in to change notification settings - Fork 4
/
store.ts
35 lines (31 loc) · 1.21 KB
/
store.ts
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
import { configureStore } from "@reduxjs/toolkit";
import catalogReducers from "@thepalaceproject/web-opds-client/lib/reducers/index";
import { State as CatalogState } from "@thepalaceproject/web-opds-client/lib/state";
import { api } from "./features/api/apiSlice";
import bookEditorSlice from "./features/book/bookEditorSlice";
import editorReducers, { State as EditorState } from "./reducers/index";
export interface CombinedState {
editor: EditorState;
catalog: CatalogState;
}
/** Build a redux store with reducers specific to the admin interface
as well as reducers from web-opds-client. */
export default function buildStore(initialState?: CombinedState) {
return configureStore({
reducer: {
editor: editorReducers,
catalog: catalogReducers,
bookEditor: bookEditorSlice,
[api.reducerPath]: api.reducer,
},
preloadedState: initialState,
devTools: process.env.NODE_ENV !== "production",
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: false,
}).concat(api.middleware),
});
}
export const store = buildStore();
export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;