如何在 Meteor(iron:router) 中进行顺序订阅

How to do sequential subscription in Meteor(iron:router)

例如,我必须这样:

Router.route('/threadList', {
waitOn: function () {
    return Meteor.subscribe('threads', Meteor.userId);
},
data: function() {
    threads = Threads.find();
    _.each(threads, function(thread) {
        _.each(thread.comments, function(commentId) {
            Meteor.subscribe('comments', commentId);
       })
   })
}

我不知道如何在 Meteor 中做这种事情

你可以查看包裹publish-composite

在您的发布代码中进行反应式连接。

只需将其添加到您的项目中即可:meteor add reywood:publish-composite

然后像这样发布:

Meteor.publishComposite('publishName', { 
    find: function() {
        return Threads.find({userId: this.userId});
    },
    children: [
        {
            find: function(thread) {
                 return Comments.find({threadId: thread._id});
            }
        }
});