Can frontend wait for API backend workflows to end?

In my app, there is a function to copy a large number of things through a loop in the API backend (I put it into the backend because I want to avoid that the copying process may possibly be interrupted due to an unexpected browser closing/crashing or so…).

My frontend then starts to display the newly created/copied things bit by bit while the copying process runs, and it doesn’t look good. And what’s even worse is that the user can already start editing the new things while the copying process is still running. Moreover, the user cannot be sure when the process is done, because I am unable to provide an announcement from the backend…

Does anyone maybe have a solution for this?

Hello!

What I usually do for this is create a new data type called loader which contains a field called isFinished? of yes/no type. After creating it and setting it to no, I send it to the backend workflow as more data. When the backend workflow, finishes, I change the isFinished? field to yes.

Meanwhile, in my frontend I setup a popup with a loading animation and set it to type: loader. I display the loader thing I created when I scheduled the backend workflow and you can play with the isFinished? condition to make it visible or invisible. This way you can make sure the user doesn’t do anything until the backend workflow is done

4 Likes

Worked for me, thanks!

This topic was automatically closed after 70 days. New replies are no longer allowed.