如果调用Meteor.subscribe反应的计算中,例如使用Tracker.autorun,当计算无效或停止订阅将自动取消;
然后明确提到,不需要在autorun
内停止订阅。
这也是流星助手的情况吗?我相信他们算作reactive computation
,但我不完全确定!
EDIT
下面是代码表示的情况的一个片段。 接下来的问题是:我需要做些什么来阻止objectsSub
或者是否全部自动排序?
<template name ="Foo">
{{#with myContext}}
{{#each objects}}
<!--Show stuff-->
{{/each}}
{{/with}}
</template>
Template.Foo.onCreated(function(){
this.subscribe('myContextSub');
});
Template.foo.helpers({
myContext(){
return MyContextCollection.findOne();
},
objects(){
Meteor.Subscribe('objectsSub',this.someContextAttribute);
return ObjectsCollection.find({});
},
});
你为什么订阅帮手?这对我来说似乎很奇怪。你能显示你的代码吗? – zim
我已经添加了一小段代码。我在帮助程序中订阅的原因是让数据上下文可用,我将能够在订阅参数 – EugVal
中使用好,我明白你在做什么。我有一个想法,我会把答案。 – zim