在客户端 MVC 中,谁应该处理客户端 - 服务器通信? [英] In client side MVC, who should handle client-server communication?

查看:32
本文介绍了在客户端 MVC 中,谁应该处理客户端 - 服务器通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发客户端/服务器产品.基本上,服务器会将文档传输到客户端进行编辑.客户端具有完整的 MVC 架构.文档就是模型.

I'm working on a client/server product. Basically, server will transfer a document to client side to do editing. The client side has full MVC architecture. The document is the model.

现在的问题是:

  1. 模型中有一些计算需要服务器中的一些资源.
  2. 出于性能原因,模型的某些部分应该延迟加载.

一个例子是文档中的图像.打开文档时它没有加载,但是有加载图像的东西,一旦加载它就会让文档知道并且文档会重新计算布局.

One example is the image in a document. It didn't load when opening the document, but there is something that load the image, once it loaded it will let the document know and document will recalculate the layout.

我的问题是通信代码是模型还是控制器的一部分?或者它属于某个既不是模型也不是控制器的上下文?还是上下文属于模型?

My question is if the communication code is part of Model or Controller? Or it belongs to some Context that is neither Model nor Controller? Or the Context belongs to Model?

推荐答案

模型层应该与数据源交互.如果客户端-服务器设置有两个独立的三元组,则客户端模型层的数据源将是服务器的表示层.

The model layer should be interacting with data source. In case of client-server setup where you have two separate and independent triads, the data source for client's model layer would be server's presentation layer.

基本上,您客户端的模型层变成了 服务器端用户.

Basically, your client-side's model layer becomes the user of server-side.

这篇关于在客户端 MVC 中,谁应该处理客户端 - 服务器通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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