Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions windows/ReactNativeAsyncStorage/DBStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ void DBStorage::DBTask::getAllKeys(sqlite3* db) {
auto writer = winrt::MakeJSValueTreeWriter();
result.WriteTo(writer);
std::vector<winrt::JSValue> callbackParams;
callbackParams.push_back(winrt::JSValueArray());
callbackParams.push_back(nullptr);
callbackParams.push_back(winrt::TakeJSValue(writer));
m_callback(callbackParams);
}
Expand All @@ -478,7 +478,7 @@ void DBStorage::DBTask::getAllKeys(sqlite3* db) {
void DBStorage::DBTask::clear(sqlite3* db) {
if (Exec(db, m_callback, u8"DELETE FROM AsyncLocalStorage")) {
std::vector<winrt::JSValue> callbackParams;
callbackParams.push_back(winrt::JSValueArray());
callbackParams.push_back(nullptr);
Copy link

Choose a reason for hiding this comment

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

you could pass JSValue::Null or even omit the nullptr altogether

Copy link
Member

Choose a reason for hiding this comment

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

@chrisglein any chance you could take a look on this suggestion?

Copy link

Choose a reason for hiding this comment

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

fwiw this should be non-blocking :)

m_callback(callbackParams);
}
}
14 changes: 7 additions & 7 deletions windows/ReactNativeAsyncStorage/RNCAsyncStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,28 @@ namespace winrt::ReactNativeAsyncStorage::implementation
}

REACT_METHOD(getAllKeys);
void getAllKeys(std::function<void(JSValueArray const& errors, JSValueArray const& keys)>&& callback) noexcept {
void getAllKeys(std::function<void(JSValue const& error, JSValueArray const& keys)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::getAllKeys,
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
auto& error = callbackParams[0];
if (callbackParams.size() > 1) {
callback(errors, callbackParams[1].AsArray());
callback(error, callbackParams[1].AsArray());
}
else {
callback(errors, {});
callback(error, {});
}
}
});
}

REACT_METHOD(clear);
void clear(std::function<void(JSValueArray const&)>&& callback) noexcept {
void clear(std::function<void(JSValue const&)>&& callback) noexcept {
dbStorage.AddTask(DBStorage::DBTask::Type::clear,
[callback{ std::move(callback) }](std::vector<JSValue> const& callbackParams) {
if (callbackParams.size() > 0) {
auto& errors = callbackParams[0].AsArray();
callback(errors);
auto& error = callbackParams[0];
callback(error);
}
});
}
Expand Down