Are there any "best practices" in terms of registering for or firing
custom events?

I notice that the GwtEvent subclasses in GWT 2.1.0.RC1 use a variety
of strategies. Some events offer a static fire() method, some events
offer a static register() method, and some events have neither option.
In addition, some events have protected constructors while others have
public constructors.

Examples:
1) com.google.gwt.event.logical.shared.ValueChangeEvent has a
protected constructor and a static fire() method.
2) com.google.gwt.requestfactory.shared.RequestEvent has a public
constructor and a static register() method.

Additionally, the javadoc in EventBus suggests that "it is rare to
call [addHandler(Type<H> type, H handler)] directly. More typically a
GwtEvent subclass will provide a static register() method, or a widget
will accept handlers directly."

This suggests that, in contrast to GWT versions pre-dating 2.1.0.RC1,
custom GwtEvent subclasses should provide a register() method, making
the static GwtEvent.Type field private.

Any recommendations on this?

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to