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"));