Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Communication between presenters #65

Closed
pinicius opened this issue May 3, 2016 · 5 comments
Closed

Communication between presenters #65

pinicius opened this issue May 3, 2016 · 5 comments
Labels

Comments

@pinicius
Copy link

pinicius commented May 3, 2016

First of all, thanks for share with community this great framework.

I've a doubt about how can I communicate two presenters without using Event Bus solution.
I've got an Editor activity with a presenter and multiple fragments, each one of them with a presenter, that be added to this activity in different steps of the process.
How can the activity's presenter know when the user has clicked on fragment list item, if user's click event is handled by fragment's presenter?

Thanks

@pedrovgs
Copy link
Contributor

pedrovgs commented May 3, 2016

Hi @pinicius!

Depending on the feature you are working on you can implement different solutions :)

If there is a change in the data handled by your application I suggest you to move the events inside your domain and implement this events mechanism inside of your domain as a core component.

If the events are not related to the business requirements and are just related to presentation layer you can connect your presenters as a dependency. The presenter A can use the presenter B as a dependency and vice versa.

If you don't want to couple your presenters you can create listeners for your fragment presenters and update the activity presenter class signature to implement these listeners. If an event is triggered by the presenter A the listener is notified and the listener implementation (the activity presenter) will notify the presenter B if needed.

Is this the answer to your question?

@pinicius
Copy link
Author

pinicius commented May 4, 2016

Thanks for your reply Pedro.

Before your answer, I was mulling the third option you mention.
But after reviewing your proposal several times, I have doubts :) Maybe first option...

I have a "WorkOrdersWizardActivity" activity that uses multiple fragments to the process of creating a work order.

Should I use the first option that you comment me in this context? How the domain entity Wizard (for example) manage this events?

Again, thanks for all.

@pedrovgs
Copy link
Contributor

pedrovgs commented May 4, 2016

You can use any approach suggested in my previous comment. Move the events to your domain means that you have to register a listener into your system and notify it once the wizard has changed. Using this approach the state of the work order will be in your domain and not in your view. Depending on the problem to solve I suggest you this approach. If you are implementing a chat, I strongly recommend you this approach, but if the code is just related to the presentation layer, do not move all that presentation logic to the domain.

@pinicius
Copy link
Author

pinicius commented May 4, 2016

Nice explanation. Thanks Pedro

@pinicius pinicius closed this as completed May 4, 2016
@pedrovgs
Copy link
Contributor

pedrovgs commented May 4, 2016

You are welcome!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants