Re: A static EventBus / SimpleEventBus: Pro Contra

2011-11-07 Thread Thomas Broyer
Injecting an EventBus allows you to pass the one instance you want (SimpleEventBus, ResettableEventBus, CountingEventBus, RecordingEventBus, or your own subtype), and change that between dev, production, and tests. -- You received this message because you are subscribed to the Google Groups

Re: A static EventBus / SimpleEventBus: Pro Contra

2011-11-07 Thread Alexander Orlov
Maybe I've misguided you mentioning the SimpleEventBus implementation of the EventBus interface. The actual question was whether I should use a *static* EventBus that can be defined in a Common class and reference this static EventBus from any other view. E.g. using *MyView() {* *// MyView

Re: A static EventBus / SimpleEventBus: Pro Contra

2011-11-07 Thread Thomas Broyer
I had understood, so that doesn't change my answer. With the static instance, everyone shares exactly the same. With an injected instance, you can wrap your global singleton eventbus within a ResettableEventBus in some cases (depending on how you manage your classes lifecycle), or some other

Re: A static EventBus / SimpleEventBus: Pro Contra

2011-11-07 Thread Jens
As GIN also supports static injection it seems like there is not much of a difference, but: 1.) Using the static way you somehow hide the fact that a class depends on an event bus 2.) Sometimes its nice to have multiple instances of an event bus. Especially having multiple ResettableEventBus's

Re: A static EventBus / SimpleEventBus: Pro Contra

2011-11-07 Thread Thomas Broyer
Sorry if I didn't make it clear enough: With the static instance, everyone shares exactly the same [instance], which means that you cannot choose, for a particular object, to use a different instance (e.g. ResettableEventBus), unless you make that object depend explicitly on the other instance

Re: A static EventBus / SimpleEventBus: Pro Contra

2011-11-07 Thread objectuser
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

A static EventBus / SimpleEventBus: Pro Contra

2011-11-06 Thread Alexander Orlov
EventBus is a really nice mechanism to *decouple methods from callbacks* by adding corresponding event handlers to an EventBus. By nature EventBus is something that should be known to both classes, the calling and the called class. So you can *1. pass an EventBus in a constructor or* *2. use a