MVP 中的模型 - 事件 [英] The Model in MVP - Events

查看:19
本文介绍了MVP 中的模型 - 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下分层架构;

介绍
服务
业务
数据

Presentation
Service
Business
Data

如果我为演示实现 MVP,我的理解是服务层代表M",即模型,我的理解是否正确?如果是这样,根据我对 MVP 的解释,该模型可以引发我的演示者会订阅的事件.这是否意味着我的服务层会引发事件?

If I implement MVP for the presentation my understanding is that the Service Layer represents the 'M' i.e. model, is my understanding correct? If so from my interpretation of MVP the model can raise events which my presenters would subscribe to. Does this mean that my service layer would raise events?

更新

此问题已被查看多次,但尚未吸引任何评论或答案,如果问题有任何问题,请发表评论,因为我想得到答案.谢谢.

This question has been viewed a number of times but has not attracted any comments or answers, if there is something wrong with the question please comment as I would like to get an answer on this. Thanks.

推荐答案

MVP 设计的 View Presenter 部分背后的基本思想是视图是轻量级的.人们放入表单和控件的大部分逻辑都存在于 Presenter 中.演示者是设计的中心站.检索数据、更新模型并引发事件以让应用程序的其他区域知道某些事情发生了变化.该模型主要关注所需数据的存储和检索.

The basic idea behind the View Presenter portion of a MVP design is that view is lightweight. Much of the logic that folks put into the form and controls reside in the Presenter. The Presenter is the grand central station of the design. Retrieving the data, updating the model, and raising events to let the other areas of the application know that something has changed. The model is mostly focuses on the storage and retrieval of the desired data.

使用 MVP 设计的关键问题是如果我撕掉 Forms X 并用 Forms Y 替换它会发生什么?如果您发现自己对演示者进行了彻底的更改以反映新的 UI,那么它可能不是一个干净的 MVP 设计.

The key question in using MVP design is what happens if I rip off Forms X and replace it with Forms Y? If you find yourself making radical changes to the presenter to reflect the new UI then likely it not a clean MVP design.

这篇关于MVP 中的模型 - 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆