Browse Source

feat: mmkv library example | added async-storage

Oleksandr Honcharov 1 year ago
parent
commit
c4647bb0ce
2 changed files with 45 additions and 0 deletions
  1. 9 0
      src/storage/index.ts
  2. 36 0
      src/storage/mmkv.ts

+ 9 - 0
src/storage/index.ts

@@ -0,0 +1,9 @@
+/*
+ * MMKV library needs prebuild
+ * with expo EAS build.
+ * For now it's disabled and
+ * waiting for dev build.
+ */
+
+// export * from './mmkv';
+export * from './async-storage';

+ 36 - 0
src/storage/mmkv.ts

@@ -0,0 +1,36 @@
+/*
+ * !WARNING
+ * CURRENTLY DISABLED
+ * TODO
+ * */
+
+// import { MMKV } from 'react-native-mmkv';
+//
+// const storageMMKV = new MMKV();
+//
+// const get = (key: string, type: StoreType) => {
+//   switch (type) {
+//     case StoreType.STRING:
+//       return storageMMKV.getString(key);
+//     case StoreType.BOOLEAN:
+//       return storageMMKV.getBoolean(key);
+//     case StoreType.NUMBER:
+//       return storageMMKV.getNumber(key);
+//   }
+// };
+//
+// const set = (key: string, value: string | boolean | number) => {
+//   storageMMKV.set(key, value);
+// };
+//
+// const remove = (key: string) => {
+//   storageMMKV.delete(key);
+// };
+//
+// export const storage = { get, set, remove };
+//
+// export enum StoreType {
+//   STRING = 'string',
+//   NUMBER = 'number',
+//   BOOLEAN = 'boolean'
+// }