53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
|
|
import { combineReducers } from 'redux';
|
|
import {
|
|
FLUSH,
|
|
PAUSE,
|
|
PERSIST,
|
|
persistReducer,
|
|
persistStore,
|
|
PURGE,
|
|
REGISTER,
|
|
REHYDRATE,
|
|
} from 'redux-persist';
|
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
|
import caseReducer from '../reducer/caseReducre';
|
|
import userSlice from '../reducer/userSlice';
|
|
import loginSlice from '../reducer/loginSlice';
|
|
import allCasesSlice from '../reducer/allCasesSlice';
|
|
import QueueSlice from '../reducer/Queue';
|
|
|
|
const rootReducer = combineReducers({
|
|
case: caseReducer,
|
|
loginInfo: loginSlice,
|
|
allCases: allCasesSlice,
|
|
user: userSlice,
|
|
queue: QueueSlice,
|
|
});
|
|
|
|
const persistConfig = {
|
|
key: 'root',
|
|
version: 1,
|
|
storage: AsyncStorage,
|
|
whitelist: ['case', 'allCases', 'common', 'user'],
|
|
blackList: ['case'],
|
|
};
|
|
|
|
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
|
|
|
const store = configureStore({
|
|
reducer: persistedReducer,
|
|
middleware: getDefaultMiddleware({
|
|
serializableCheck: {
|
|
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
|
|
},
|
|
}),
|
|
});
|
|
|
|
export const persistor = persistStore(store);
|
|
export default store;
|
|
|
|
export type RootState = ReturnType<typeof store.getState>;
|
|
export type AppDispatch = typeof store.dispatch;
|