The scenario: In my application, I have different types of models from different data sources that my presenter needs, eg UserState and Tasks. I have created two seperate repositories for both of these models namely, UserStateRepository and TaskRepository.
Both of these are injected into the TaskPresenter to show tasks and user specific info based on data from both the repositories.
In fact this is just one scenario. My app has many such models, eg Dictionary, Resources, etc. Almost every presenter for a view needs two repositories injected: UserStateRepository and the "MetaInformation"Repository. Hence I end up with at least 7 different repositories.
PS: I use Dagger2 to inject these repositories, but only the user state repository is an application level singelton whereas other repositories generally have activity level scope. This is because I need to refresh the cache of other activity scoped repositories everytime a new instance of an activity is created but the userstate must persist.
The question: Does this architecture actually make sense or is there a better solution? Also how about handling different lifecycles of these repositories
Aucun commentaire:
Enregistrer un commentaire