Skip to content

Commit

Permalink
feat: Migrate Redux store from AsyncStorage to MMKV
Browse files Browse the repository at this point in the history
  • Loading branch information
Ldoppea committed Dec 20, 2024
1 parent 492f132 commit dda60da
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,29 @@ import {
persistReducer,
persistStore
} from 'redux-persist'
import AsyncStorage from '@react-native-async-storage/async-storage'
import logger from 'redux-logger'

import konnectorLogsSlice from '/redux/KonnectorState/KonnectorLogsSlice'
import currentKonnectorSlice from '/redux/KonnectorState/CurrentKonnectorSlice'
import { shouldEnableReduxLogger } from '/core/tools/env'
import { storage as mmkvStorage } from '/libs/localStore'

const persistConfig = {
key: 'root',
storage: AsyncStorage
storage: {
getItem: (key: string): unknown => {
const value = mmkvStorage.getString(key)
return Promise.resolve(value)
},
setItem: (key: string, value: string): unknown => {
mmkvStorage.set(key, value)
return Promise.resolve(true)
},
removeItem: (key: string): unknown => {
mmkvStorage.delete(key)
return Promise.resolve()
}
}
}

const rootReducter = combineReducers({
Expand Down

0 comments on commit dda60da

Please sign in to comment.