Skip to content

Commit

Permalink
fix: Use argument count of 1 for MMKV constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Sep 16, 2021
1 parent ec8fe06 commit 070a462
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion android/src/main/cpp/cpp-adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void install(jsi::Runtime& jsiRuntime) {
// MMKV.createNewInstance()
auto mmkvCreateNewInstance = jsi::Function::createFromHostFunction(jsiRuntime,
jsi::PropNameID::forAscii(jsiRuntime, "mmkvCreateNewInstance"),
0,
1,
[](jsi::Runtime& runtime,
const jsi::Value& thisValue,
const jsi::Value* arguments,
Expand Down
6 changes: 3 additions & 3 deletions ios/Mmkv.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void install(jsi::Runtime & jsiRuntime)
// MMKV.createNewInstance()
auto mmkvCreateNewInstance = jsi::Function::createFromHostFunction(jsiRuntime,
jsi::PropNameID::forAscii(jsiRuntime, "mmkvCreateNewInstance"),
0,
1,
[](jsi::Runtime& runtime,
const jsi::Value& thisValue,
const jsi::Value* arguments,
Expand All @@ -34,11 +34,11 @@ static void install(jsi::Runtime & jsiRuntime)
throw jsi::JSError(runtime, "MMKV.createNewInstance(..) expects one argument (object)!");
}
jsi::Object config = arguments[0].asObject(runtime);

NSString* instanceId = [Mmkv getPropertyAsStringOrNilFromObject:config propertyName:"id" runtime:runtime];
NSString* path = [Mmkv getPropertyAsStringOrNilFromObject:config propertyName:"path" runtime:runtime];
NSString* encryptionKey = [Mmkv getPropertyAsStringOrNilFromObject:config propertyName:"encryptionKey" runtime:runtime];

auto instance = std::make_shared<MmkvHostObject>(instanceId, path, encryptionKey);
return jsi::Object::createFromHostObject(runtime, instance);
});
Expand Down

0 comments on commit 070a462

Please sign in to comment.