kutaisan-react-native-mmkv-storage
Version:
This library aims to provide a fast & reliable solution for you data storage needs in react-native apps. It uses [MMKV](https://github.com/Tencent/MMKV) by Tencent under the hood on Android and iOS both that is used by their WeChat app(more than 1 Billion
35 lines (31 loc) • 846 B
JavaScript
import { handleActionAsync, handleAction } from "../handlers";
const INDEX_TYPE = "numberIndex";
export default class numbersIndex {
constructor(id) {
this.instanceID = id;
}
async getKeys() {
return await handleActionAsync(
global.getIndexMMKV,
INDEX_TYPE,
this.instanceID
);
}
hasKey(key) {
let keys = handleAction(global.getIndexMMKV, INDEX_TYPE, this.instanceID);
return keys.indexOf(key) > -1;
}
async getAll() {
return new Promise((resolve) => {
let keys = handleAction(global.getIndexMMKV, INDEX_TYPE, this.instanceID);
let items = [];
for (let i = 0; i < keys.length; i++) {
let item = [];
item[0] = keys[i];
item[1] = global.getNumberMMKV(keys[i], this.instanceID);
items.push(item);
}
resolve(items);
});
}
}