Skip to content

Commit

Permalink
perf: use multiGet instead of iteratively getting data from storage
Browse files Browse the repository at this point in the history
  • Loading branch information
hurali97 committed Jun 20, 2024
1 parent cd09aa1 commit 6ebe8a1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Onyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ function connect<TKey extends OnyxKey>(connectOptions: ConnectOptions<TKey>): nu
}

// We did not opt into using waitForCollectionCallback mode so the callback is called for every matching key.
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < matchingKeys.length; i++) {
OnyxUtils.get(matchingKeys[i]).then((val) => OnyxUtils.sendDataToConnection(mapping, val as OnyxValue<TKey>, matchingKeys[i] as TKey, true));
}
Storage.multiGet(matchingKeys).then((values) => {
values.forEach(([key, val]) => {
OnyxUtils.sendDataToConnection(mapping, val as OnyxValue<TKey>, key as TKey, true);
});
});
return;
}

Expand Down

0 comments on commit 6ebe8a1

Please sign in to comment.