Skip to content

Commit

Permalink
release 1.0.0-alpha.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Aug 26, 2023
1 parent 61e32b2 commit ab4c8e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
15 changes: 12 additions & 3 deletions ios/MMKVNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ @implementation MMKVNative
NSMutableDictionary *serviceNames;
SecureStorage *_secureStorage;
NSString *appGroupId;
NSMutableDictionary *indexes;
NSMutableDictionary *indexingEnabled;


RCT_EXPORT_MODULE()

Expand All @@ -57,6 +60,7 @@ + (BOOL)requiresMainQueueSetup {
- (instancetype)init
{
self = [super init];
indexingEnabled = [NSMutableDictionary dictionary];
RCTExecuteOnMainQueue(^{

NSString *rootDir;
Expand Down Expand Up @@ -157,12 +161,12 @@ void setServiceName(NSString *alias, NSString *serviceName) {
kv = [MMKV mmkvWithID:ID mode:mode];
}
[mmkvInstances setObject:kv forKey:ID];

return kv;
}

NSMutableDictionary *indexes;

void setIndex(MMKV *kv, NSString *type, NSString *key) {
if (!indexingEnabled[[kv mmapID]]) return;
NSMutableDictionary *index = getIndex(kv, type);

if (!index[key]) {
Expand All @@ -172,6 +176,8 @@ void setIndex(MMKV *kv, NSString *type, NSString *key) {
}

NSMutableDictionary *getIndex(MMKV *kv, NSString *type) {
if (!indexingEnabled[[kv mmapID]]) return [NSMutableDictionary dictionary];

NSMutableDictionary *index;

if (!indexes[type] && [kv containsKey:type]) {
Expand All @@ -183,6 +189,7 @@ void setIndex(MMKV *kv, NSString *type, NSString *key) {
}

void removeKeyFromIndexer(MMKV *kv, NSString *key) {
if (!indexingEnabled[[kv mmapID]]) return;
NSMutableDictionary *index = getIndex(kv, @"stringIndex");

if (index[key]) {
Expand Down Expand Up @@ -276,7 +283,7 @@ static void install(jsi::Runtime &jsiRuntime, std::shared_ptr<react::CallInvoker
});


CREATE_FUNCTION("setupMMKVInstance", 4, {
CREATE_FUNCTION("setupMMKVInstance", 5, {
NSString *ID = nsstring(arguments[0]);

MMKVMode mode = (MMKVMode)(int)arguments[1].getNumber();
Expand All @@ -287,6 +294,8 @@ static void install(jsi::Runtime &jsiRuntime, std::shared_ptr<react::CallInvoker

auto *kv = getInstance(ID);

indexingEnabled[ID] = arguments[4].getBool() ? @YES : @NO;

migrateKV(kv);

return Value(true);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-mmkv-storage",
"version": "0.10.0-alpha",
"version": "0.10.0-alpha.1",
"description": "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 users). Unlike other storage solutions for React Native, this library lets you store any kind of data type, in any number of database instances, with or without encryption in a very fast and efficient way.",
"main": "./dist/index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion src/mmkvloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default class MMKVLoader {
/**
* Provide a custom key to encrypt the storage. Use this if you dont want to generate the key automatically.
* You must call withEncryption() to use this.
* To store your key for later use call withSecureKeyStorage() too.
*
* @param key the key to encrypt the storage with
* @param secureKeyStorage Should the key be stored securely.
Expand Down

1 comment on commit ab4c8e1

@vercel
Copy link

@vercel vercel bot commented on ab4c8e1 Aug 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rnmmkv – ./

rnmmkv.vercel.app
rnmmkv-ammarahm-ed.vercel.app
rnmmkv-git-master-ammarahm-ed.vercel.app

Please sign in to comment.