Improvising Noah code to send different Data as well.

public class MyEvent<T> extends GwtEvent<MyEvent.Handler>

{

    public static enum EventTypes

    {

        THIS_EVENT,

        THAT_EVENT;

    };



    public interface Handler<T> extends EventHandler

    {

        void onDispatch(MyEvent<T> event);

    }


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


    private final EventTypes type;


    private T result;



    public MyEvent(EventTypes type, T result)

    {

        this.type = type;

        this.result = result;

    }


    @Override

    public GwtEvent.Type<Handler> getAssociatedType()

    {

        return TYPE;

    }



    public EventTypes getType()

    {

        return type;

    }


    @Override

    protected void dispatch(Handler handler)

    {

        handler.onDispatch(this);

    }

    /**

     *

     * @return result

     */

    public T getResult() {

        return result;

    }


}

On Wed, Jan 6, 2016 at 3:25 AM, N Troncoso <[email protected]> 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 the Google Groups
> "GWT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
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