PubSub和方法之间的区别 [英] Difference between PubSub and Methods

查看:137
本文介绍了PubSub和方法之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Meteor中的 PubSub Methods 有什么区别?!

What is the difference between PubSub and Methods in Meteor?!

我可以将方法"放在发布"之类的服务器文件夹中吗?

Can I put Methods in Server folder like Publishs?

在我看来也是一样,但是方法更具反应性.

To me seen like the same, but Methods is more reactive.

推荐答案

它们是同一枚硬币的两个不同面.这是流星中数据生命周期的图形:

They are two different sides of the same coin. Here's a drawing of the data lifecycle in meteor:

  • 发布 -哪些数据是从服务器
  • 订阅 -客户端使用哪些数据请求发布
  • > 方法 -如何从客户端操作数据在服务器上
    • 注意-通常会在客户端和服务器上同时运行.客户端将预测服务器将执行的操作,以便可以立即进行更新.然后,当在服务器上运行该方法并做出规范决策时,延迟补偿将开始执行.
    • Publish - Which data is sent from the server
    • Subscribe - Which data the client requests publications for
    • Methods - How to manipulate data from the client on the server
      • Note - this will typically be run on both on the client and the server. The client will make a prediction as to what the server will do so it can update right away. Then latency compensation will kick in when the method is run on the server and the canonical decision is made.

      这篇关于PubSub和方法之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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