hi..
i'm re-posting this, as i'm not sure the original post was ... posted, as i
havn't goined the group when i wrote it..
..
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
final static EventFactory<String> myEvent1 =new EventFactoy<String>();
eventbus.addHandler(myEvent,new GenericEventHandler<Sting>(){
..
}
fire( myEvent1.create("sds"));
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/jH5HYlShQWEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.