osh
osh

Reputation: 1261

What exactly is the difference between an app specific event and a GWT event and when is one supposed to be used over the other?

While consulting the javadocs for GwtEvent class this text snippet got me confused:

There is no need for an application's custom event types to extend GwtEvent. Prefer Event instead.

Can someone please give a concrete situation example where Event is preferred to the gwtevent class? Should ClearEvent ( defined here : http://alextretyakov.blogspot.ro/2011/11/gwt-event-bus-basics.html ) extend GwtEvent class or should it directly extend Event class?

Upvotes: 2

Views: 67

Answers (1)

Olivier Tonglet
Olivier Tonglet

Reputation: 3502

GwtEvent extends Event. It just seems that the GWT team need some functionalities for most of its events. But you probably don't need those.

In our application most events are consumed directly. So we don't need to have those isLive(), kill(), revive() methods. I guess it's the same for most people.

IMO such methods are required when a chain of listeners can catch the event and forward it to each other. You would want to mark the event as "processed" to avoid it being consumed when the processing is over.

The code in the post you provided is not using those methods. So the answer is: the author didn't need to extends GWTEvent. Event will work just fine.

Upvotes: 3

Related Questions