-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More improvements for Onyx.connect
(After cache)
#78
Comments
Very cool! I love this! |
@kidroca should we maybe break these 2 issues up into individual issues to focus on in isolation? |
The first part of the ticket might not be necessary, the result of
Hmm yeah they are similar, but the idea here is to use We can probably close this ticket and keep the newer one |
Alright sounds good. I'm going to close up this issue then. It would be great if we can pull out some of these observations and focus on each one in isolation. I'm trying to help funnel these ideas into actionable steps but having issues like "optimize x" and "improve y" make it pretty tricky to tell what is what. |
Also, let's move these issue into |
There are some more improvements that can be done to the
connect
function specifically for storage accessing1. Improvements regarding the
getAllKeys
usage inconnect
react-native-onyx/lib/Onyx.js
Lines 373 to 382 in 27c0ba8
It serves to distinct any collection keys when connecting to a collection - something that ATM is not possible without first retrieving all storage keys
The above wasn't easy to tell by the code itself, I only find out when debugging
So we only need
getAllKeys
when we're dealing with a collection to get a list of collection item keys -matchingKeys
Otherwise we're always connecting to a single key -
mapping.key
An oversimplified example
2. Values can be retrieved using
multiGet
We already have a list of keys and we can use
multiGet
instead of retrieving each key separatelyreact-native-onyx/lib/Onyx.js
Lines 389 to 401 in 27c0ba8
This can instead be:
Currently there's no
multiGet
definition in Onyx, but we can add one and hook it to cache as well.It can check if any of the keys are available in cache and only call
AsyncStorage.multiGet
with the remaining, then cache each key/val from the resultAs we've seen from previous benchmarks: Expensify/App#2762 (comment) retriving multiple items in parallel even with cache is flooding the bridge with calls (when data is not available in cache e.g. startup)
The text was updated successfully, but these errors were encountered: