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]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
