What is the lifecycle of the MVP components?

337 Views Asked by At

Which component does the application start from? Where should they be created? (If the view is activity, and if you need to respect the independence of the components). Under what conditions can exist multiple Model or Presenter components? And who should manage the change and the creation of them?

i have no answer for my all questions about mvp lifecycle, so if somebody can continue Rohit answer - please

1

There are 1 best solutions below

2
On BEST ANSWER

Model is responsible for giving the data whatever your requirements are. Presenter act as a mediator b/w View and Model and contains the business logic(the manipulation of data according to the users requirements) View is the part which is visible to the users all your S.D.K. related code will be here and the part which is visible to the user will be here.

Notes. 1.The View will communicate with the presenter to get Data from model 2.Model will get the data and give to presenter 3. Presenter will do if any modifications in the data is required and give it to View 4.The View and Model will not contact each other directly 5.All the logic will be in presenter so that it can be tested separately

For Android The View is Activity where android related data will be present which are a part of Android S.D.K. and it will ask presenter for data which will contact the Model which will give you data from server or locally or from anywhere which will get back back to presenter then to view The Android related data will be in View only and all the things which requires activity or android context should take place in view only The Presenter will contain the business logic so that we can write JUNIT tests on it