Server calls should be avoided on client events (On Initialize, On Ready, On Render, On After Fetch) so instead of call server action insider client event or client actions , i put the server action inside fetch data from other source is that going to be good practice and solve the issue ?
is it ok to call Fetch data from other source after that aggregate fetch the data instead of calling server action inside the after fetch
Hey Omar!Assuming you´re talking about reactive applications I would advise you to consult the Screen and Block Lifecycle Events documentation available here: https://success.outsystems.com/documentation/11/developing_an_application/implement_application_logic/screen_and_block_lifecycle_events/
Server Calls should be avoided on the 'OnInitialize' client action because it will cause a delay to the screen's render. To avoid performance issues, just like you mentioned, you should fetch data from other sources like Aggregates or Data Actions depending on your app architecture.Both Data Actions and client-side Aggregates concurrently start to fetch data after the Screen loads by default although you can also only fetch data on demand, when you desire.
I hope I have been of some help
Hello Omar,
I would like to add few points to what Jose mentioned above.
You can place fetch from other source data action in the after fetch client action of an aggregate.
In Outsystems, aggregates and data actions runs in no specific order. So If you keep data action as at start it will run along with aggregate at start and when aggregate fetches data it will run again as we refreshed it.
So the best way is to set data action as On demand and use it in after fetch.
Similar to this, we can also refresh other aggregate which is set as On demand in after fetch.
Example
Perfect example for this scenario is Countries and States
Consider the output of the country aggregate is a country and you have to get states by that country, then in the after fetch action we can refresh state aggregate or state data action which is set as On demand. By this server call, we can get states belonging to that specific country.
So, you can place data action (fetch from other source) in after fetch action of aggregate by using above method.
Hope this helps you.