-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.js
47 lines (41 loc) · 1.08 KB
/
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
40
41
42
43
44
45
46
47
import { AsyncStorage } from '@react-native-community/async-storage';
import {
createStore,
combineReducers,
compose,
applyMiddleware
} from 'redux';
import thunk from 'redux-thunk';
import {
persistStore,
autoRehydrate
} from 'redux-persist';
import createFilter from 'redux-persist-transform-filter';
import { reducer as dataReducer } from './data/reducer';
import { reducer as servicesReducer } from './services/reducer';
import * as persistActionCreators from './services/persist/actions';
const appReducer = combineReducers({
services: servicesReducer,
data: dataReducer,
});
const enhancer = compose(
applyMiddleware(
thunk,
)
)
const store = createStore(
appReducer,
enhancer,
autoRehydrate(),
);
const saveAndLoadSessionFilter = createFilter(
'services',
['session'],
['session']
);
export const persist = persistStore(store, {
storage: AsyncStorage,
blacklist: ['data'],
transforms: [saveAndLoadSessionFilter],
}, () => store.dispatch(persistActionCreators.update({ isHydrated: true })));
export default store;