How to avoid performance suggestion warnings regarding onReady action

How to avoid performance suggestion warnings regarding onReady action

  

Hi,

In our app we have several "performance suggestion" warnings regarding using local storage 

Performance Suggestion
'OnReady' contains accesses to the local storage or server, which delays the block's render. To avoid performance issues, use Aggregates or Data Actions instead.

What is the best way to avoid it if there is a need to run client side actions with access to local storage or server actions when the screen loaded? For now we came up with having dummy "Fetch Data from other sources" with obligatory output parameter and having OnAfterFetch client action where we moved actions from the onReady event. Is this a best option?

Thank you for suggestions :)

Mykola (Nick) Tkachenko wrote:

Hi,

In our app we have several "performance suggestion" warnings regarding using local storage 

Performance Suggestion
'OnReady' contains accesses to the local storage or server, which delays the block's render. To avoid performance issues, use Aggregates or Data Actions instead.

What is the best way to avoid it if there is a need to run client side actions with access to local storage or server actions when the screen loaded? For now we came up with having dummy "Fetch Data from other sources" with obligatory output parameter and having OnAfterFetch client action where we moved actions from the onReady event. Is this a best option?

Thank you for suggestions :)


The best option is definitely to do those actions on the end of the OnAfterFetch client action, doing that means that the screen will render first and then whenever the query is done, those actions will run.

If you need the result of those actions to show values on the screen, be sure to set dummy placeholder "elements" in those values before the "IsDataFetched" is done.

something like this https://cloudcannon.com/deconstructions/2014/11/15/facebook-content-placeholder-deconstruction.html

Hi Frederico,

Thanks for reply. Then does it matter in terms of performance if that onAfterFetch is for "Fetch Data from other sources"  or "Fetch Data from Local Storage" ? I suspect it should be faster to use it with some empty or frequently used local entity getting some simple value.  

but your client actions use the local storage, can't you use that local aggregate to get the data that you need?

in some case sure. but if there is a login like depending on input parameter run different aggregates it is to possible to use local aggregate that way.

You can use your input parameter inside the aggregate, can i get more details on your use case? i might be able to help you out better.