MMKVAdapter
MMKVAdapter is a lightweight implementation of the StorageAdapter using react-native-mmkv. It plugs into the SchemaVersionedStorageWrapper, allowing you to have all the advantages of the wrapper with MMKV as the underlying storage mechanism.
For full details on schema migrations and the overall API, please refer to the SchemaVersionedStorageWrapper README.
Features
- Implements the
StorageAdapter using react-native-mmkv
- Designed for use with SchemaVersionedStorageWrapper
Installation
yarn add @lukso/controllerapps-sharedlogic-mmkv-adapter
Ensure you have set up MMKV properly in your React Native project. Follow the installation guide.
Usage
The MMKVAdapter is used internally by the higher-level MMKVStore (which wraps SchemaVersionedStorageWrapper). For example:
import { MMKVConfiguration } from 'react-native-mmkv';
import { MMKVAdapter } from '@lukso/controllerapps-sharedlogic-mmkv-adapter';
const configuration: MMKVConfiguration = {...}
const adapter = new MMKVAdapter(configuration);
(async () => {
const store = await SchemaVersionedStorageWrapper.load(
adapter,
'profiles',
migrations
)
await store.put({ name: 'Alice', age: 28 });
})();