From 6ebe8a1f30ed8ce3a6d63164e07fa4d2a4a9b09b Mon Sep 17 00:00:00 2001 From: hurali97 Date: Thu, 20 Jun 2024 14:52:49 +0500 Subject: [PATCH] perf: use multiGet instead of iteratively getting data from storage --- lib/Onyx.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Onyx.ts b/lib/Onyx.ts index 04ddcee9..e7372326 100644 --- a/lib/Onyx.ts +++ b/lib/Onyx.ts @@ -155,10 +155,11 @@ function connect(connectOptions: ConnectOptions): 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, matchingKeys[i] as TKey, true)); - } + Storage.multiGet(matchingKeys).then((values) => { + values.forEach(([key, val]) => { + OnyxUtils.sendDataToConnection(mapping, val as OnyxValue, key as TKey, true); + }); + }); return; }