Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent method call until Async Call Completes GWT-Platform

In my GWT-Platform application I have implemented method in which one step is to fetch data from server and next step is dependent on it. I want to prevent my method for further execution of the code until the Async call completes.

Should be something simple but I am not finding a way.

like image 847
Bhavesh Avatar asked Jan 16 '23 08:01

Bhavesh


1 Answers

I think you are missing the point about the web being asynchronous.

It is not considered good practice (it is rather an anti-pattern) to block the execution of your client side code until the async call is finished.

So instead of blocking the execution until your async code is finished do following:

  1. Create a Event which is fired on the global Eventbus when your async code is finished
  2. Attach a Handler for this event in one of your Presenters
  3. Start the async code
  4. Show a loading indicator
  5. When the async call is finished hide the loading indicator and fire the Event on the Eventbus
  6. Handle the next step in the Handler you created before.
like image 55
Ümit Avatar answered Feb 24 '23 14:02

Ümit