You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In App Startup cycle, as a result of Onyx.Connect calls we execute this method each time. We roughly have more than 30 connections which happens in App Startup cycle. As a result, each time a new array is created from the set.
Solution
We can improve this by checking whether the keys have changed and if they have changed, we create a new array and store it to a variable. And then the next time getAllKeys is invoked we will just return this variable if no keys are changed.
Let’s see how it looks like in action:
// In OnyxCache.js
constructor() {
...
this.keysArray = [];
this.hasChanged = false;
...
}
getAllKeys() {
if (this.hasChanged) {
this.keysArray = Array.from(this.storageKeys);
}
this.hasChanged = false;
return this.keysArray;
}
addKey(key) {
……
this.hasChanged = true;
}
merge(data){
.....
this.storageKeys = new Set([...storageKeys, ...mergedKeys]);
// set the flag to indicate that the keys have changed
this.hasChanged = true;
.....
}
drop(key) {
……
this.hasChanged = true;
}
This issue has not been updated in over 15 days. @hurali97 eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Problem
In OnyxCache.js we have getAllKeys method, which upon invocation generates a new Array from the set and returns it. Below is how it looks as of yet:
In App Startup cycle, as a result of Onyx.Connect calls we execute this method each time. We roughly have more than 30 connections which happens in App Startup cycle. As a result, each time a new array is created from the set.
Solution
We can improve this by checking whether the keys have changed and if they have changed, we create a new array and store it to a variable. And then the next time getAllKeys is invoked we will just return this variable if no keys are changed.
Let’s see how it looks like in action:
From @hurali97
The text was updated successfully, but these errors were encountered: