tooot/src/store.ts

36 lines
944 B
TypeScript
Raw Normal View History

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-12-13 14:04:25 +01:00
import instancesSlice from '@utils/slices/instancesSlice'
import settingsSlice from '@utils/slices/settingsSlice'
2020-11-21 13:32:29 +01:00
const secureStorage = createSecureStore()
const instancesPersistConfig = {
key: 'instances',
storage: secureStorage
}
const settingsPersistConfig = {
key: 'settings',
storage: secureStorage
}
2020-10-31 21:04:46 +01:00
const store = configureStore({
reducer: {
instances: persistReducer(instancesPersistConfig, instancesSlice),
settings: persistReducer(settingsPersistConfig, settingsSlice)
2020-11-22 00:46:23 +01:00
},
middleware: getDefaultMiddleware({
serializableCheck: {
ignoredActions: ['persist/PERSIST']
}
})
})
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>