dimanche 18 décembre 2016

Android: MVP. Right way to communicaticate between components

I have implemented MVP pattern in my application. I have an additional layer which I call Repository, which is responsible for running HTTP asynchronous requests. I have created OnTaskCompleteListener interface for communication between Repository and Model (Model implements OnTaskCompleteListener). So when Repository finishes the request, it calls a method in Model and updates data. Then, Model calls a method in Presenter with the same mechanism, to let it know that Model has been updated. What I am worrying, is the chain of callbacks that comes from Repository up to Presenter. Is there a better way to communicate between components of MVP or is it the way to go? I did try "EventBus", but a large number of needed interfaces scared me off. Observer did not seem fit as there is only one listener for each component (Model listens to Repository, Presenter listens to Model). Thank you.

Aucun commentaire:

Enregistrer un commentaire