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

2013-07-13 Thread Magnus
Hi, thanks to all. Yes, using the onSuccess method is the way to go. But it requires additional member variables and - if there were more such cases - this could get a little bit ugly. But it's ok for now. Magnus -- You received this message because you are subscribed to the Google Groups "G

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

2013-07-10 Thread Ümit Seren
I think the big advantage of Promises/Futures is that you can pass a Future/Promise around. It also makes handling multiple asynchronous easier than with callbacks (chaining vs nested callbacks). Of course they have to be non-blocking. Java8 and it's lambda constructs would make things much less v

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

2013-07-10 Thread Jens
> In general these kind of scenarios would be a good fit for > Futures/Promises especially if you depend on multiple asynchronous calls. > https://code.google.com/p/gwt-async-future/ IMHO Futures don't buy you anything in GWT. In Java Future.get() blocks until the result is available, in GWT

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

2013-07-10 Thread Ümit Seren
I think this solution is the right one. In general these kind of scenarios would be a good fit for Futures/Promises especially if you depend on multiple asynchronous calls. https://code.google.com/p/gwt-async-future/ https://code.google.com/p/gwtquery/wiki/Promises On Tuesday, July 9, 2013

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

2013-07-09 Thread Jens
If inviter is a required information then make it a constructor arg: private final AsyncCallback> loadUsersCallback; public InvitationForm(final int inviter) { loadUsersCallback = new AsyncCallback>() { void onSuccess(final List users) { fillList(users); select(inviter); }

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

2013-07-09 Thread Magnus
Hi Jens, yes, there are many options, but as I wrote, there are always some annoying things that make the code unattractive somehow. The options 2) and 3) require an additional member variable to hold the inviter's value until the server call returns, and finally you end up in redundancy: The

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

2013-07-08 Thread Jens
Somewhat depends on the concrete case, there is probably not the one solution that always fits. 1.) Dependency Inject: Load the list externally, e.g. new InvitationForm(users). As setInviter() depends on the list its not a good idea to use invitationForm.setUsers() because then you still need t

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

2013-07-08 Thread Magnus
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 asynch