/** * React Native Storage Adapter * * This adapter provides synchronous localStorage-like behavior using MMKV * MMKV is a fast, synchronous key-value storage for React Native * * Installation: * npm install react-native-mmkv * * Alternative: If you prefer AsyncStorage, you'll need to handle async operations differently */ import { MMKV } from 'react-native-mmkv' import type { StorageAdapter } from 'tf-checkout-shared' const mmkvStorage = new MMKV() export const reactNativeStorageAdapter: StorageAdapter = { getItem: (key: string): string | null => { try { const value = mmkvStorage.getString(key) return value ?? null } catch (error) { console.error(`[StorageAdapter] getItem error for key "${key}":`, error) return null } }, setItem: (key: string, value: string): void => { try { mmkvStorage.set(key, value) } catch (error) { console.error(`[StorageAdapter] setItem error for key "${key}":`, error) } }, removeItem: (key: string): void => { try { mmkvStorage.delete(key) } catch (error) { console.error(`[StorageAdapter] removeItem error for key "${key}":`, error) } }, }