I have 2 presenters/view. Lets call them parent and child. parent presenter is a container (using slot mechanism) for the child presenter.
In the child presenter's view user clicked button and I would like to handle this action in parent presenter.
How can I do this? What is the best approach? Should I use some kind of event and eventhandler? Or should I inject one presenter to the other?
Both are possible.
For events - GWTP have a simplified version of GWT events:
So in your child presenter you'll simply do:
and to register it, in the parent, you'd either use:
or
if you want it to be processed only when the parent is visible. I suggest you yo add these handlers in onBind method of your presenter (don't forget to call super.onBind() first when overriding)
For injection: Simply make sure:
To avoid circular dependency error in GIN do not wire it like
@Inject ParentPresenter presenter;
instead do it like this:
and access it with
presenterProvider.get()in your child