My apps front end makes several calls to an external analytics API to show stats on my dashboard. The API calls are set up via the connector with the type of ‘Data’
Question is - how can I conditionally show a loading icon in the front end whilst I wait for those calls to run and respond? I haven’t been able to find a way yet and it would massively improve the page experience!
If you already know how to show a loader you are one step in the right direction. If not, first search that or check out my this tutorial
Once you know how to do the loader, you can set things up based on the :count of the repeating group you are displaying the API results in…if the count is 0 assume it is loading
Although I don’t think this fits your specific scenario, for those who use a RepeatedGroup, you can use the is loading state: States - Bubble Docs (it’s a shame they didn’t generalize this for any element that uses an API call or other data source that requires a fetch over the network).
This doesn’t handle the case when a descendant element in your RepeatedGroup makes another API call based on the parent group’s object for that row. For that situation, I’ve used a separate loader per row, that starts off visible, but is hidden when the Parent group's value is not empty. (This approach could possibly work in your case.) But I don’t see any good way to have a single spinner represent the total loading state of all its children right now.
Hey yes I did do that in the end and it works pretty well.
I have a custom state on the element called Loading yes/no.
When it’s set to ‘yes’ the animation shows, stops when it’s no.
So then I use a workflow, and at the start set the loading state to yes, get the data in the next step, then in the final step set the loading status back to no.
Here’s how it looks in UI, note the loading animation on the top stats starts and stops when the data is loaded