Files
by-other-means/src/store/store.ts
T
2026-07-29 04:02:16 -04:00

35 lines
966 B
TypeScript

import { combineReducers, configureStore } from "@reduxjs/toolkit";
import { persistReducer, persistStore } from "redux-persist";
import storage from "redux-persist/es/storage";
import phaseReducer from "./slices/phaseSlice";
import timeReducer from "./slices/timeSlice";
const persistConfig = {
key: "root",
storage: storage,
whitelist: ["time", "phase"],
};
const rootReducer = combineReducers({
time: timeReducer,
phase: phaseReducer,
});
const persistedReducer = persistReducer(persistConfig, rootReducer);
export const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: ["persist/PERSIST", "persist/REHYDRATE"],
},
}),
});
export const persistor = persistStore(store);
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
export type AppStore = typeof store;