2020-11-22 00:46:23 +01:00
|
|
|
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
|
2020-11-21 13:32:29 +01:00
|
|
|
import { persistReducer, persistStore } from 'redux-persist'
|
|
|
|
import createSecureStore from 'redux-persist-expo-securestore'
|
2020-10-24 02:47:57 +02:00
|
|
|
|
2020-12-13 14:04:25 +01:00
|
|
|
import instancesSlice from '@utils/slices/instancesSlice'
|
|
|
|
import settingsSlice from '@utils/slices/settingsSlice'
|
2020-10-24 02:47:57 +02:00
|
|
|
|
2020-11-21 13:32:29 +01:00
|
|
|
const secureStorage = createSecureStore()
|
|
|
|
|
|
|
|
const instancesPersistConfig = {
|
|
|
|
key: 'instances',
|
|
|
|
storage: secureStorage
|
|
|
|
}
|
|
|
|
|
2020-11-29 13:11:23 +01:00
|
|
|
const settingsPersistConfig = {
|
|
|
|
key: 'settings',
|
|
|
|
storage: secureStorage
|
|
|
|
}
|
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
const store = configureStore({
|
2020-11-21 00:40:55 +01:00
|
|
|
reducer: {
|
2020-11-29 13:11:23 +01:00
|
|
|
instances: persistReducer(instancesPersistConfig, instancesSlice),
|
|
|
|
settings: persistReducer(settingsPersistConfig, settingsSlice)
|
2020-11-22 00:46:23 +01:00
|
|
|
},
|
|
|
|
middleware: getDefaultMiddleware({
|
|
|
|
serializableCheck: {
|
|
|
|
ignoredActions: ['persist/PERSIST']
|
|
|
|
}
|
|
|
|
})
|
2020-10-24 02:47:57 +02:00
|
|
|
})
|
2020-10-31 21:04:46 +01:00
|
|
|
|
2020-11-21 13:32:29 +01:00
|
|
|
let persistor = persistStore(store)
|
2020-10-31 21:04:46 +01:00
|
|
|
|
2020-11-21 13:32:29 +01:00
|
|
|
export { store, persistor }
|
2020-10-31 21:04:46 +01:00
|
|
|
export type RootState = ReturnType<typeof store.getState>
|