janishar / android-mvp-interactor-architecture

Extension of the android-mvp-architecture for very large projects.
Apache License 2.0
405 stars 97 forks source link

Is an Interactor allowed to depend on more than one repositories? #7

Open mradzinski opened 6 years ago

mradzinski commented 6 years ago

Hi, just stumbled with your articles on medium and had this quick question regarding the interactor pattern: is an Interactor supposed to have one and only one dependency on a repository or can actually depend on more than one?

For example: Lets suppose that we have a UserProfileInteractor wich has only one method called GetUser and a UserRepository which has N methods (doesn't matter which ones for the sake of the example). Now, that user needs to belong to a Company and that model "belongs" to its own repository called CompanyRepository which has other methods, but specifically one called getCompany that we'll need to invoke to assemble our user on the UserProfileInteractor. For completeness we also have a presenter called UserProfilePresenter which will have an instance of UserProfileInteractor and is in charge of "presenting" the user profile displaying the user information + that user's company data.

How would you handle such a thing? Would you make UserProfileInteractor have dependencies on both UserRepository and CompanyRepository? Would an interactor depending on two repositories violate the separation of concerns in any way?

Cheers and thanks for the articles, really enjoying them.

wengelef commented 6 years ago

yes