On Tuesday, November 8, 2011 1:40:25 PM UTC+1, tanteanni wrote:
>
> Thx Thomas,
>
> "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?" 
>
> I think that's wrong in my case. ActivityManagers are provides this way 
> in my code:
>     @Provides
>     @Singleton
>     @Named("ContentArea")
>     public final ActivityManager getContentActivityManager(final 
> ContentMapper activityMapper, final EventBus eventBus) {
>         return new ActivityManager(activityMapper, eventBus);
>     }
> The eventBus is provided 
> via bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class); At 
> the Moment i change the package the compilation fails for my activities
>

OK, let's start from the beginning: what do you mean exactly by "the 
compilation fails" ? Java compilation ? GWT compilation ? where exactly and 
with which error ?

 

> (another question is why new ActivityManager is accepting eventBus from 
> both packages).
>

In that particular case, because it has both constructors, with gwt 
EventBus (deprecated) and with web.bindery EventBus; but if it hadn't (to 
maintain binary compatibility), as gwt EventBus extends web.bindery 
EventBus, polymorphism would do the rest (and thus it would maintain source 
compatibility).
 

> Correct me if i am wrong: you suggest to give activity's start method the 
> old eventbus
>

You have no choice but use the deprecated EventBus as the formal argument 
to your activities' start() method.
The GWT team cannot change the definition of Activity to use the 
web.bindery EventBus, because that would be a breaking change (you'd have 
to go through all your activities to change the EventBus type to the 
web.bindery one).
And you cannot declare it as a web.bindery EventBus (even though it's a 
superclass of the gwt EventBus) because Java doesn't support contravariance 
of argument types (that'd declare an overload, not an override; see 
http://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)#Java
 )
 

> (but this one shouldn't be used).
>

Why wouldn't you use it? The eventbus passed as argument to your start() 
method is *not* your global eventbus (as given to the ActivityManager), 
it's a ResettableEventBus built around it, so that you don't have to bother 
unregistering your handlers.
It's there to help you, so use it!

but because the activity managers are calling the start method with their 
> eventbus i have to provide activitymanagers constructed with the old 
> eventBus?
>

No (see above); it doesn't matter which kind of EventBus you give to the 
ActivityManager, it will wrap it in a ResettableEventBus and give that one 
to your activity.
 

> (i don't really understand the code you provided, is "injector.eventBus()" 
> the old or the new EventBus)
>

Everything in the first part uses the web.bindery EventBus.

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