I'd like to suggest writing more documentation using the MVP approach and EventBus with Custom GWT Event handlers for say a larger de-coupled GWT application.
I think a great example would be writing a GwtEvent based on [Google] Logged in/out on app engine. Once the rpc call comes back from the server, it could fire this event below depending on what happened.
Maybe an auth event could go like this... The documentation gurus might be able to come up with something better :)
public class AuthEvent extends GwtEvent<AuthEventHandler> {
public static Type<AuthEventHandler> TYPE = new Type<AuthEventHandler>();
public static enum Auth {
/**
* user was logged in
*/
LOGGEDIN,
/**
* user logged out
*/
LOGGEDOUT;
}
private Auth auth;
private UserData userData;
public AuthEvent(Auth auth) {
this.auth = auth;
userData = null;
}
public AuthEvent(Auth auth, UserData userData) {
this.auth = auth;
this.userData = userData;
}
@Override
public Type<AuthEventHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(AuthEventHandler handler) {
handler.onAuthEvent(this);
}
public Auth getAuthEvent() {
return auth;
}
public UserData getUserData() {
return userData;
}
}
public interface AuthEventHandler extends EventHandler {
public void onAuthEvent(AuthEvent event);
}
public class UserData implements IsSerializable {
/**
* Google User Id
*/
private Long id;
private String nickName;
private String userId;
private String email;
private boolean isAdmin;
private boolean isLoggedIn;
public UserData() {
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getNickName() {
return nickName;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return userId;
}
public void setEmail(String email) {
this.email = email;
}
public String getEmail() {
return email;
}
public void setIsAdmin(boolean isAdmin) {
this.isAdmin = isAdmin;
}
public boolean getIsAdmin() {
return isAdmin;
}
public void setIsLoggedIn(boolean isLoggedIn) {
this.isLoggedIn = isLoggedIn;
}
public boolean getIsLoggedIn() {
return isLoggedIn;
}
public String toString() {
String s = "";
s += "id=" + id + " ";
s += "nickName=" + nickName + " ";
s += "userId=" + userId + " ";
s += "email=" + email + " ";
s += "isAdmin=" + isAdmin + " ";
s += "isLoggedIn=" + isLoggedIn + " ";
return s;
}
}