Answer the question
In order to leave comments, you need to log in
Number of Model in MVP android?
Hello, I am studying the architecture of MVP applications and seem to understand its essence. I read various implementation recommendations that each View is recommended to have its own Presenter. In Model, I realized that it is separated and returns data through callback.
But I don't understand the intricacies of Model.
Suppose there is a simple application - the administrator of the store. There are several tables in the database: "product", "customers", "purchases". Each list has its own View + Presenter. What about Model? it acts as one for all 3 tables; goes 1k1 (1 table - 1 Model); or 1 - customers, 2 - product, 3 - adjacent to the first two?
And how is the Model interface implemented in the Presenter then?
Answer the question
In order to leave comments, you need to log in
Model - the level that provides data
Alternatively, for each user case, you can use your own level of business logic. The presenter of, say, a screen with a list of clients accesses the interface of an interactor or a class that encapsulates getting a list of clients (Repository)
ClientsPresenter <-> ClientsRepository <-> Db
PurchasesPresenter <-> PurchasesInteractor <-> PurchasesRepository <-> Db
The presenter knows about interactor/repository and retrieve data using callback implementations or, for example, using RxJava.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question