Projekt

Obecné

Profil

Stáhnout (1.45 KB) Statistiky
| Větev: | Tag: | Revize:
1 930b05fd Schwobik
import { configureStore } from "@reduxjs/toolkit"
2 80bb10d9 Michal Schwob
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 930b05fd Schwobik
import userReducer from "./reducers/userSlice"
6 97deff21 Fantič
import itemReducer from "./reducers/itemSlice"
7 9c55d3bb Schwobik
import searchFormReducer from "./reducers/searchFormSlice"
8
import listViewReducer from "./reducers/listViewSlice"
9 4da7b143 Schwobik
import homePageReducer from "./reducers/homePageSlice"
10 bb690a9a Fantič
import noteViewReducer from "./reducers/notesSlice"
11 930b05fd Schwobik
12 80bb10d9 Michal Schwob
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 8bb5689a Michal Schwob
export const store = configureStore({
30 80bb10d9 Michal Schwob
    reducer: persistedReducer,
31
    middleware: (getDefaultMiddleware) =>
32
        getDefaultMiddleware({
33
            serializableCheck: {
34
                ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
35
            },
36
        })
37 5ed9692c Schwobik
})
38
39 8bb5689a Michal Schwob
export const Persistor = persistStore(store)
40
41
export default { store, Persistor }
42 5ed9692c Schwobik
export type RootState = ReturnType<typeof store.getState>
43
export type AppStore = typeof store
44
export type AppDispatch = typeof store.dispatch