Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom storage with react-native-mmkv, need help. #75

Open
abdullahIsa opened this issue Jul 18, 2022 · 0 comments
Open

custom storage with react-native-mmkv, need help. #75

abdullahIsa opened this issue Jul 18, 2022 · 0 comments

Comments

@abdullahIsa
Copy link

Hello, need a bit of help i want to use another storage, i find react-native-mmkv good and fast, not sure if will improve performance but i want to give it a try, it seems to not work and throws an error, some of the storage functions I dont know yet how to get them from react-native-mmkv but may i know what the proper way to use this two together?

import {MMKV} from 'react-native-mmkv';
let options = {};
const StorageMMKV = {
  config: customOptions => {
    options = {
      ...options,
      ...customOptions,
    };
  },
  setItem: (key, value, cb) => {
    MMKV.set(key, value);
    cb(null, value);
  },
  multiSet: (value, cb) => {
    cb(null, value);
  },
  getItem: (key, cb) => {
    const value = MMKV.getString(key);
    cb(null, value);
  },
  removeItem: (key, cb) => {
    MMKV.delete(key);
    cb(null, key);
  },
  getAllKeys: cb => {
    const keys = MMKV.getAllKeys();
    cb(null, keys);
  },
  mergeItem: (key, cb) => {
    cb(null, key);
  },
  multiGet: (keys, cb) => {
    cb(null, keys);
  },
  multiSet: (keyValuePairs, cb) => {
    cb(null, keyValuePairs);
  },
  multiRemove: (keys, cb) => {
    cb(null, keys);
  },
  multiMerge: (keyValuePairs, cb) => {
    cb(null, keyValuePairs);
  },
  clear: cb => {
    MMKV.clearAll();
    cb(null, true);
  },
};
export {StorageMMKV};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant