官术网_书友最值得收藏!

  • JavaScript:Moving to ES2015
  • Ved Antani Simon Timms Narayan Prusty
  • 219字
  • 2021-07-09 19:07:38

The Model-View-Presenter pattern

Model-View-Presenter is a variation of the original MVC pattern that we discussed previously. Both MVC and MVP target the separation of concerns but they are different on many fundamental aspects. The presenter in MVP has the necessary logic for the view. Any invocation from the view gets delegated to the presenter. The presenter also observes the model and updates the views when the model updates. Many authors take the view that because the presenter binds the model with views, it also performs the role of a traditional controller. There are various implementations of MVP and there are no frameworks that offer classical MVP out of the box. In implementations of MVP, the following are the primary differences that separate MVP from MVC:

  • The view has no reference to the model
  • The presenter has a reference to the model and is responsible for updating the view when the model changes

MVP is generally implemented in two flavors:

  • Passive view: The view is as na?ve as possible and all the business logic is within the presenter. For example, a plain Handlebars template can be seen as a passive view.
  • Supervising controller: Views mostly contain declarative logic. A presenter takes over when the simple declarative logic in the view is insufficient.

The following figure depicts MVP architecture:

主站蜘蛛池模板: 沂源县| 广安市| 龙川县| 时尚| 抚顺县| 顺义区| 棋牌| 斗六市| 和田市| 南部县| 北宁市| 都江堰市| 万州区| 安远县| 扶绥县| 舒城县| 游戏| 桂东县| 都安| 京山县| 甘谷县| 富阳市| 西安市| 徐汇区| 阆中市| 贞丰县| 霍林郭勒市| 永德县| 嘉义县| 洞口县| 中宁县| 高碑店市| 栾川县| 德庆县| 惠东县| 乐安县| 安化县| 会同县| 威海市| 潮安县| 江安县|