Not that it's really what you asked (I agree with the replies you've 
received), but if you're using the idiom shown in some of the Google 
presentations/samples/vids, instead of direct references to the EventBus 
instance (which is a class and not an interface ... I don't know why), you 
may have something like this:

MyEvent.register(...);
MyEvent.fire(new MyEvent(...));

That's pretty convenient, but suffers from the same problem mentioned in 
the other replies.

I've gone to something like this:

I inject/construct with instances of a class like MyEventBroker, which 
looks like:

public class MyEventBroker {
  EventBus eventBus;
  public MyEventBroker(EventBus eventBus) { ... }
  public HandlerRegistration registerEventOneHandler(...) { ... }
  public void fireEventOne(EventOne eventOne) { ... }
  public HandlerRegistration registerEventTwoHandler(...) { ... }
  public void fireEventTwo(EventTwo eventTwo) { ... }
  ...
}


I used to have a lot of events, but since moving to MVP, I have far fewer. 
 Nevertheless, I find it convenient, while YMMV.

Anyway, most of my classes don't need direct references to EventBus 
instances, just the MyEventBroker instance.  I never liked the static 
methods I saw in the Google samples.  Statics always seem to bite me if I 
am not careful, and messing with my testing seems to be one of the first 
places.

-- 
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/-/KWXsPY461d0J.
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.

Reply via email to