Prevent method call until Async Call Completes GWT-Platform

gwt, gwt-platform

Solution

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:

- Create a Event which is fired on the global Eventbus when your async code is finished

- Attach a Handler for this event in one of your Presenters

- Start the async code

- Show a loading indicator

- When the async call is finished hide the loading indicator and fire the Event on the Eventbus

- Handle the next step in the Handler you created before.

Problem

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.

Original source