-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.js
39 lines (31 loc) · 1007 Bytes
/
store.js
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
36
37
38
39
import {createStore, compose, applyMiddleware, combineReducers} from 'redux';
import {repoReducer} from './src/domains/repo/Reducers';
import {connectionReducer} from './src/domains/connection/Reducers';
import thunk from 'redux-thunk';
import AsyncStorage from '@react-native-community/async-storage';
import {
createMigrate,
persistStore,
persistCombineReducers,
REHYDRATE,
PURGE,
} from 'redux-persist';
const persistConfig = {
version: 1,
key: 'root',
storage: AsyncStorage,
whitelist: ['repoState'],
};
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const persistedReducer = persistCombineReducers(persistConfig, {
repoState: repoReducer, // per salvare l'input dell'utente
connectState: connectionReducer, // per gestire la connessione
});
const store = createStore(
persistedReducer,
composeEnhancers(applyMiddleware(thunk)),
);
const persistor = persistStore(store, null, () => {
store.getState();
});
export {store, persistor};