Hi Thomas,

I understand EventBus is for decoupling things .. but I guess there are
sometimes where you would want to use multiple (local) event bus.

I don't know may be I am missing something .. let me explain you my case

I have a DockPanel where I have added Widgets (panels) on West, Center &
East directions.

The panel on the west side contains navigation links and when clicked the
content is displayed on the center panel.

I was able to do the above navigation & displaying because the DockPanel was
the part of main presenter/view and I could easily access the DockPanel and
change the content of center panel.

But there is a time when I have a TabPresenter (which has a Tabpanel) into
my center panel, and in the first panel of TabPanel there is a button which
should fetch some data from server and display it in the second panel of
TabPanel.

Now if I do this using the app wide EventBus bus, I won't have access to the
TabPanel because it's inside of TabPresenter, in the app wide EventBus I
could only create TabPresenter and add it to center panel but cant access
TabPanel.

or should I have getTabPanel in Dispay of TabPresenter and manipulate it in
app wide eventbus ? I don't think this should be done like this.

a local EventBus which will be a part of TabPresenter will be good for this
case I guess.


- Abdullah

On Fri, Jan 29, 2010 at 3:00 PM, Thomas Broyer <[email protected]> wrote:

>
> On Jan 29, 8:46 am, Mirco Dotta <[email protected]> wrote:
> > Hi,
> >
> > This is a question I've been asking myself several times, here is the use
> > case:
> >
> > I've got an action happening in a ChildPresenter, such as a
> > DeleteElementEvent.
> > The ParentPresenter would like to register to this type of events so that
> a
> > correct
> > reaction can be triggered.
> >
> > Now, a possible way to go is to pass the Event in the EventBus and having
> > the ParentPresenter
> > registering on the EventBus for such events. This is going to work, but I
> > really don't like this
> > solution as the Event is not application-wide and therefore should not be
> > polluting the event bus.
> >
> > I'd rather have a local event, but how can I achieve this? Should I
> create a
> > HandlerManager
> > it in the ParentPresenter... but then hwo can I pass it to the children
> (GIN
> > injection?!, but how?).
> >
> > I'm looking for a pattern, if anyone faced the problem and came up with a
> > solution, please share :)
>
> The EventBus is there to help you decouple things. If you want to
> "couple" them, then it's OK to not use the EventBus (you've been
> warned about strong coupling and its implication on code maintability
> though)
>
> You could follow the same pattern that is used in GWT widgets:
>  - have a HandlerManager in ChildPresenter
>  - ChildPresenter expose a addDeleteElementHandler method that adds
> the handler in the internal HandlerManager
>  - the ParentPresenter registers its handler directly on the
> ChildPresenter
>  - ChildPresenter fires the event at its internal HandlerManager
> rather than the EventBus
>
> This is really strong coupling though. You've been warned...
>
> Another solution would be to have several event buses.
>
> But actually I don't really understand why it is a problem to fire the
> event at the EventBus if you already have one...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-web-toolkit%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
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