Thursday, June 26, 2014

Why not use class name as the TYPE of the event

Hi all,

A custom event needs to have a TYPE variable to denote the type of the event. For example:

public class LogoutEvent extends Event<LogoutEventHandler>
{
public static Type<LogoutEventHandler> TYPE = new Type<LogoutEventHandler>();
@Override
protected void dispatch(LogoutEventHandler handler)
{
handler.onLogout();
}

@Override
public com.google.web.bindery.event.shared.Event.Type<LogoutEventHandler> getAssociatedType()
{
return TYPE;
}

}


I am just curious about the need to have the TYPE field. Why GWT could not use the class name of the event(in this case LogoutEvent) to denote the type of the event. Only purpose I see of this type is to have it as a key in the map of events and their handlers. I think even the class name could have served as the key in this map.

Thanks
Ganesh

--
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/d/optout.

No comments:

Post a Comment