1
|
import { configureStore } from "@reduxjs/toolkit"
|
2
|
import { persistStore, persistReducer, FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER} from "redux-persist"
|
3
|
import { combineReducers } from "redux"
|
4
|
import AsyncStorage from "@react-native-async-storage/async-storage"
|
5
|
import userReducer from "./reducers/userSlice"
|
6
|
import itemReducer from "./reducers/itemSlice"
|
7
|
import searchFormReducer from "./reducers/searchFormSlice"
|
8
|
import listViewReducer from "./reducers/listViewSlice"
|
9
|
import homePageReducer from "./reducers/homePageSlice"
|
10
|
import noteViewReducer from "./reducers/notesSlice"
|
11
|
|
12
|
const persistConfig = {
|
13
|
key: "root",
|
14
|
storage: AsyncStorage,
|
15
|
whitelist: ["user"],
|
16
|
}
|
17
|
|
18
|
const reducers = combineReducers({
|
19
|
user: userReducer,
|
20
|
itemViewState: itemReducer,
|
21
|
noteViewState: noteViewReducer,
|
22
|
searchForm: searchFormReducer,
|
23
|
listView: listViewReducer,
|
24
|
homePage: homePageReducer
|
25
|
})
|
26
|
|
27
|
const persistedReducer = persistReducer(persistConfig, reducers)
|
28
|
|
29
|
export const store = configureStore({
|
30
|
reducer: persistedReducer,
|
31
|
middleware: (getDefaultMiddleware) =>
|
32
|
getDefaultMiddleware({
|
33
|
serializableCheck: {
|
34
|
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
|
35
|
},
|
36
|
})
|
37
|
})
|
38
|
|
39
|
export const Persistor = persistStore(store)
|
40
|
|
41
|
export default { store, Persistor }
|
42
|
export type RootState = ReturnType<typeof store.getState>
|
43
|
export type AppStore = typeof store
|
44
|
export type AppDispatch = typeof store.dispatch
|