Wednesday, July 10, 2013

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

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 5:13:18 PM UTC+2, Jens wrote:
If inviter is a required information then make it a constructor arg:

private final AsyncCallback<List<User>> loadUsersCallback;
public InvitationForm(final int inviter) {
  loadUsersCallback = new AsyncCallback<List<User>>() {
    void onSuccess(final List<User> users) {
       fillList(users);
       select(inviter);
    }
  }
}

@Override
protected void onLoad() {
   super.onLoad();
   service.getUsers(loadUsersCallback);
}

That's what I would have done, but maybe I don't get your use case correctly ;-) So far I never really needed this scheduleDeferredWhenServerCallReturned feature, as I already have it.. its the onSuccess() method and I would rethink what I am doing until I can implement onSuccess() the way it should be.

-- J.

--
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