0
我試圖找到最好的實踐,我們如何更新內部跟蹤器authorun;自動運行內更新集合,無需重新運行(Meteor.JS)
例如,我想更新我收藏中的視圖數。但我想確保我的訂閱已準備就緒,並且我有工作的對象;
例如在onCreated部分:
var self = this;
self.autorun(function() {
var topicId = FlowRouter.getParam('_id');
self.subscribe('Topic', topicId);
if(self.subscriptionsReady()){
// var topic = Topic.findOne(topicId);
// topic.upViews();
}
});
此代碼將變爲無限循環,因爲我們註釋掉的代碼將改變對象。在這種情況下如何做到最好?非常感謝你!
這就是實現它的方法。 –
@MichelFloyd你好!謝謝! –