205
Views
4
Comments
Progress bar(Loader)  for Long Server Call
Question
Application Type
Mobile

I want the loader in Progress bar format if it is for client action i can update value for the number of time i need like 20%,50%,75%,80% etc..., but if am calling a single server action  which is calling multiple server action in that i need to notify the user how much completed like that how can i do this?

How to calculate  that?


2023-04-06 11-24-23
Paulo Zacarias

Hi sasikumar S, 

What you can do is divide that one server action into multiple ones, each one will trigger an event when finished, the progress bar gets updated and the next server action is called. Like a step-by-step process where each step corresponds to a server action.

Just an idea.

Regards, 

PZ

UserImage.jpg
SASIKUMAR S

Hi paulo,

Thanks for replying

Splitting server into may will cause to multiple server hit also will cause architecture issue am i right? 


2023-04-06 11-24-23
Paulo Zacarias

Hi sasikumar, 

Yes, it will have more server calls, but you don't need to have dozens of them. It was just an idea to divide your main server action into multiple ones, let's say 4, each one corresponding to 25% of the progress, for instance.

In terms of architecture, I don't see any issues. 

Although it is recommended to minimize server calls when possible as a best practice, the number of these does not constitute an architecture issue.

Regards, 

PZ

2023-10-21 19-42-11
Tousif Khan
Champion

Hello,

I don't understand how we can progress the loader, which is on client Side.

Because when you click on the screen action it will trigger the server action,

And once you get into a server action everything becomes synchronous, and  how you are going to manage the output, which says 10 percent completed  then 20 and so on.

let me make it more detailed.

So you perform an action which is executing multiple server action, now you want to show the progress on a loader or a progress bar.

This can be a workaround I can say which you can do.

You need to create a temp entity which will hold the percentage of completion, 

  • Now after each step or after each server action completed its task update the percentage in your entity, and since it is running in a single transaction you need to use a commit transaction so that the data you are writing get stored and available to you on client side.
  • Now you need to refresh the aggregate that will hold the percentage, so you need to trigger a client action again and again to refresh the aggregate again and increase the progress 
  • The percentage of progress is saving in the entity and should be bind to your progress bar.
  • Now the  screen action that will refresh the aggregate holding the percentage value,You need to run it in a interval so that it will refresh again and again.
  • To do that you need to write a JS code and use setInterval function.
  • Make sure you are fetching the correct data from the aggregate.
  • To get accurate data you can add some flags or useridentifier.

This is one way. Other  way is using realtime data base or web sokets.


Thanks
Tousif Khan

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.