Monday, July 8, 2013

how to defer a method call until the return of an async server call?

Hi,

I use a form called "InvitationForm" to let the user create an invitation for a game, like this:

InvitationForm f = new InvitationForm();
...
f.setInviter(...);

In this case, the call to setInviter selects an entry in a list of users.
Unfortunately, the list of users is fetched by an asynchroneous server call, and the call might not have returned when setInviter is called.
Then, the setInviter method cannot do its work, because the list is still empty.

Of course, there are many ways to get along with this, e. g. storing the user identity in an additional class member variable within setInviter and doing the list selection when the server call returns.
I also used to use Scheduler.get().scheduleDeferred to get things done somewhat later, but in this case, it would not be guaranteed that the call has returned then.

Since this happens often, what would be an elegant way to do this?

Magnus

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate