如果調用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