defining custom events without the boilerplate code?
16 views
Skip to first unread message
Elhanan
unread,
Jun 19, 2011, 10:23:16 AM6/19/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-we...@googlegroups.com
hi.. after reading about custom events in gwt i understand that for each custom events you must: 1. define an event handler which events EventHandler 2. create an event class which extends Event 3. define a static Type<MyHandler> inside the event (return that type on the method) 4. add the handler to the event bus 5. fire the event
BUT why shouldn't i do the following: 1. create a generic eventHandler interface like so: public interface GenericEventHandler<P> extends EventHandler{ public void onEvent(P p); } create an event factory which extends type
public class EventFactory<P> extends Event.Type<GenericEventHandler<P>> { public Event create(P p){ return new Event(){ public Type<GenericEventHandler<P>> getType(){ return MessageFactory.this; } public dispatch (GenericEventHandler h){ h.onEvent(p); } } } }
from then on all i would need to do this for each new event