The question is: if only Activity uses the "old" event bus, and that one 
happens to be provided by ActivityManager (which has a dependency on the 
"new" event bus), and why couldn't you use the "new" event bus everywhere 
else than the Activity#start method?

bind(com.google.web.bindery.event.shared.EventBus.class).to(com.google.web.bindery.event.shared.SimpleEventBus.class).in(Singleton.class);

@Provides PlaceController 
providePlaceController(com.google.web.bindery.event.shared.EventBus bus) {
   return new PlaceController(bus);
}
@Provides PlaceHistoryHandler providePlaceHistoryHandler(PlaceHistoryMapper 
mapper) {
   return new  PlaceHistoryHandler(mapper);
}
...
ActivityManager manager = new ActivityManager(injector.activityMapper() // 
simplification: assumes a single ActivityManager/ActivityMapper
                            injector.eventBus());
manager.setDisplay(display);

PlaceHistoryHandler phh = injector.placeHistoryHandler();
phh.register(injector.placeController(), injector.eventBus(), defaultPlace);
phh.handleCurrentHistory();

Everything above compiles OK, right?

Now, why that class would make it fail to compile then:
class MyActivity extends AbstractActivity {
   public void start(AcceptsOneWidget 
panel, com.google.gwt.event.shared.EventBus bus) {
      panel.setWidget(new Label("Hello World!");
   }
}

The activity has no dependency on the singleton/global event bus, and the 
one passed to its start() method doesn't come from GIN; so what's the 
problem?

And if you need to get injected the global event bus, for whatever reason, 
then just do it:

import com.google.web.bindery.event.shared.EventBus;
class MyActivity extends AbstractActivity {
   @Inject EventBus globalBus;

   public void start(AcceptsOneWidget 
panel, com.google.gwt.event.shared.EventBus bus) {
      panel.setWidget(new Label("Hello World!");
      globalBus.fireEvent(new StartedEvent("hello world"));
   }
}

-- 
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/-/d0Jg6FOXL98J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to