订阅时是否Meteor.publish return 旧数据?
Does Meteor.publish return old data when subscribe?
在显微镜下,pagination part。 /10
将加载 10 个帖子,/20
将加载 20 个帖子。
所以首先 subscribe('posts', {limits: 10})
,发布 return 10 个帖子,然后
subscribe('posts', {limits: 20})
,将 return 发布全部 20 个帖子,还是只发布 return 个新的 10 个帖子?
如果我明白了,问题基本上就是:"does meteor resend records that are already on the client when re-subscribing"。答案是否定的,可以在 Meteor docs for subscribe
中找到
Meteor is smart enough to avoid wasteful unsubscribing/resubscribing
Meteor 足够聪明,可以跟踪每个客户为每个发布者拥有的当前文档集。当发布者重新运行时,它知道只发送集合之间的 差异 。让我们以下面的序列为例:
- 订阅帖子:
a,b,c
- 重新运行帖子订阅
b,c,d
- 服务器为
a
发送一条 removed
消息,为 d
发送一条 added
消息。
请注意,如果您在重新运行之前停止订阅,则不会发生这种情况。
在显微镜下,pagination part。 /10
将加载 10 个帖子,/20
将加载 20 个帖子。
所以首先 subscribe('posts', {limits: 10})
,发布 return 10 个帖子,然后
subscribe('posts', {limits: 20})
,将 return 发布全部 20 个帖子,还是只发布 return 个新的 10 个帖子?
如果我明白了,问题基本上就是:"does meteor resend records that are already on the client when re-subscribing"。答案是否定的,可以在 Meteor docs for subscribe
中找到Meteor is smart enough to avoid wasteful unsubscribing/resubscribing
Meteor 足够聪明,可以跟踪每个客户为每个发布者拥有的当前文档集。当发布者重新运行时,它知道只发送集合之间的 差异 。让我们以下面的序列为例:
- 订阅帖子:
a,b,c
- 重新运行帖子订阅
b,c,d
- 服务器为
a
发送一条removed
消息,为d
发送一条added
消息。
请注意,如果您在重新运行之前停止订阅,则不会发生这种情况。