MVP Pattern
Explore the MVP pattern and its role in separating presentation logic from UI in JavaScript. Understand how model, view, and presenter interact, and learn its advantages for complex views, user interactions, and easier testing.
We'll cover the following...
What is the MVP pattern?
The MVP pattern stands for model view presenter. It is derived from the MVC pattern, which focuses on the user interface. MVP however, is focused on improving the presentation logic.
It consists of three components:
-
Model: provides the data that the application requires, which we want to display in the view
-
View: to display the data from the model, it passes the user actions/commands to the presenter to act upon that data
-
Presenter: acts as the middle man between the model and the view. Retrieves data from the model, manipulates it, and returns it to view for display. It also reacts to the user’s interaction with the view.
...