Hi Richa,

Have you looked at EventBinder?

https://github.com/google/gwteventbinder

Pablo

On Jan 5, 2016, at 5:15 PM, Richa 
<richa.kulka...@gmail.com<mailto:richa.kulka...@gmail.com>> wrote:

Thanks Troncoso.
I get what you say, and agree that its not a very good approach.
But my concern is, For a huge application having around 200 events . Will I 
have to write 200 Event handlers, 200 Event Classes and Event types ?

On Tue, Jan 5, 2016 at 4:55 PM, N Troncoso 
<noah.tronc...@gmail.com<mailto:noah.tronc...@gmail.com>> wrote:
You could technically do that, but you'd need some way to differentiate between 
events; Maybe with an enum:

public class MyEvent extends GwtEvent<MyEvent.Handler>
{
    public static enum EventTypes
    {
        THIS_EVENT,
        THAT_EVENT;
    };

    public interface Handler extends EventHandler
    {
        void onDispatch(MyEvent event);
    }

    public static final GwtEvent.Type<Handler> TYPE = new GwtEvent.Type<>(); // 
NOSONAR

    private final EventTypes type;
    public MyEvent(EventTypes type)
    {
        this.type = type;
    }

    @Override
    public GwtEvent.Type<Handler> getAssociatedType()
    {
        return TYPE;
    }

    public EventTypes getType()
    {
        return type;
    }

    @Override
    protected void dispatch(Handler handler)
    {
        handler.onDispatch(this);
    }
}

I don't think this is a very good approach, though, as you lose the ability to 
pass specific parameters based on that particular kind of event.


--
You received this message because you are subscribed to a topic in the Google 
Groups "GWT Users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/google-web-toolkit/l0aEL5fsAok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
google-web-toolkit+unsubscr...@googlegroups.com<mailto:google-web-toolkit+unsubscr...@googlegroups.com>.
To post to this group, send email to 
google-web-toolkit@googlegroups.com<mailto:google-web-toolkit@googlegroups.com>.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
google-web-toolkit+unsubscr...@googlegroups.com<mailto:google-web-toolkit+unsubscr...@googlegroups.com>.
To post to this group, send email to 
google-web-toolkit@googlegroups.com<mailto:google-web-toolkit@googlegroups.com>.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to