Closed pinicius closed 8 years ago
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?
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.
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.
Nice explanation. Thanks Pedro
You are welcome!
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