A repeat loops through a set of data… In the case of an api call (assuming you mean a call outside of the repeat, not within it) the api call is made once and it will store whatever the api returns. The repeat is available to then loop through the data results, without making any subsequent calls to the api.
Conversely if you put an api action inside a repeat, it will make a call to that api for each iteration of the repeat.
So if an API returns 20 results, if I use a repeat on the api data array - it will keep through each one of the 20- this being quite slow/draining on performance?
I’ve never noticed a performance issue on a repeat. If you need to process something in the array, you do a repeat. If you don’t need loop through them all, then don’t do a repeat.
You will notice performance issues only when you have too many repeats on a single page.
Or, if each row in the repeat has some complex condition going on to either format the data or show hide certain elements etc.
The best approach (has been discussed somewhere in community) is to make sure maximum formatting & conditional flags etc are taken care of in the server action part itself. For eg: You want to show a date in some particular format, try using custom query which formats date in SQL itself, rather than doing it client side.
In your case, if the API in question is in your control, you should re-work it to keep minimum data-changes on the client side repeat (i.e. DMX dependent). For 20 rows, I don’t think its much of an issue. I have worked with 100s of rows with minimal performance issues.
Another helpful tip (again has been discussed somewhere in the community) is to use conditional regions if you page has too many dynamic stuff going on and you can see a performance issue.
AppConnect is not as “powerful” as react or angular in this department.
@mebeingken - so would you say that a repeat is not actually doing anything with that data again, i.e. it’s just ‘redisplaying’ it, rather than repeating the data source (e.g. two loads). ? Or if an API call returns 10 results, will the repeat essentially loop through the 10 results, and this increase load slightly?
Sorry, I just don’t understand what you are trying to deal with here, but will say that you always want the underlying array of a repeat to be as small as possible – in other words, if you aren’t going to use it, then get it out of the array. But once you have the appropriate array for the repeat, just let it do its work.
Just feels like you are trying to prevent a problem that doesn’t exist.
I’m not trying to do anything - the post is a question to better understand how this works within Wappler so I can use appropriately. Nothing wrong with trying to get a better understanding to avoid future issues.
And I’m not exactly trying to prevent a problem that doesn’t exist - when sid above confirms that there can be performance issues with the repeat is mishandled. Thanks anyway, will keep exploring and testing.