title: Event bus review
body: <p>I'm starting with <em>GWT</em> and learning <em>Event bus</em> concepts now. I find this solution extremely complicated. So I tried to simplify it by writing prototype by myself to see all problems.</p>
  
  <p>At first I will write about my understanding of event bus (that can be completely wrong).
  We have events like this</p>
  
  <pre><code>public class FooEvent extends GwtEvent&lt;FooHandler&gt; {
      public static Type&lt;FooHandler&gt; TYPE = new Type&lt;FooHandler&gt;(); //as event type integer ID
  
      //for.. hm.. probably some inner use in Event Bus
      @Override public Type&lt;FooHandler&gt; getAssociatedType() {
          return TYPE;
      }
  
      //for handling
      @Override protected void dispatch(FooHandler handler) {
          handler.someMethod(this);
      }
  }
  </code></pre>
  
  <p>handler interface, </p>
  
  <pre><code>public interface FooHandler extends EventHandler {
      void someMethod(FooEvent event);
  }
  </code></pre>
  
  <p>usage </p>
  
  <pre><code>eventBus.addHandler(FooEvent.TYPE, new FooHandler() {
      @Override
      public void someMethod(FooEvent event) {
          //bla-bla
      }
  });
  eventBus.fireEvent(new FooEvent());
  </code></pre>
  
  <p>Thats it. And now my prototype.</p>
  
  <pre><code>//replaced GwtEvent
  interface UniGwtEvent { 
  }
  
  //than, event pretty simple
  public class FooEvent extends UniGwtEvent  {
  }
  //replaced GwtEventHandler. You should not create special handler class per event!
  public interface UniEventHandler&lt;T extends UniGwtEvent&gt; {
      void handle(T event);
  }
  //event bus prototype(in pseudocode)
  class UniEventBus {
      //map. keys getted from class. as I understand, it's possible from GWT 1.5 see http://code.google.com/p/google-web-toolkit/issues/detail?id=370 
      public &lt;T extends UniGwtEvent&gt; void addListener(Class&lt;T&gt; event, UniEventHandler&lt;T&gt; handler){
          map.put(event.getName(), handler);
      }
      public void fireEvent(UniGwtEvent event){
          if(map.contains(event.getClass().getName())){
              map.get(event).handle(event);
          }
      }
  }
  </code></pre>
  
  <p>usage </p>
  
  <pre><code>eventBus.addListener(FooEvent.class, new UniEventHandler&lt;FooEvent&gt;(){
      @Override
      public void handle(FooEvent event) {
          bla-bla
      }
  });
  eventBus.fireEvent(new FooEvent());
  </code></pre>
  
  <p>I think this solution is much better since you shouldn't make unnecessary <code>Type</code> manipulation and create Handler Class per event. I see only one disadvantage - you should specify generic type on handler creation. But I suppose there are many other disadvantages or ever issues that makes this solution impossible. What are they?</p>