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 to call 
them in the correct order.
2.) Observer pattern: Use EventBus or 
invitationForm.addUsersLoadedHandler() depending on the separation you want
3.) "Replay" method call: remember the fact that setInviter() has been 
called and do the actual work once the users list is loaded. This can be 
annoying to write if you have multiple methods that depend on the users 
list.
4.) Distinct load() method with callback: Introduce 
InvitationForm.loadUsers(new Callback<S, F> callback() {}); and call it 
externally. S is the type for onSuccess, F for onFailure. Both can be Void 
if you are not interested in them.
5.) Refactor code so that an inviter does not depend on the list of users 
he/she can invite. I would understand if the list of users depends on the 
inviter (because the users are friends or similar of the inviter) but the 
other way around sounds strange to me.

Personally I have never done 3.) so far.

I would always start with 5.) and then if the InvitationForm isn't widely 
used probably 1.). If the form is used in multiple areas I would stick to 
2) or 4). In case of 2.) I would use EventBus if parties that are 
interested in this information might be "far away" from the InvitationForm. 
If only the parent is interested in this information the 
addUsersLoadedHandler() approach makes more sense to me.

-- 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to