3
// server/publications.js
Meteor.publish('crewMessages', function(crewId) { 
  return CrewMessages.find({crewId: crewId}, {sort: {submitted: -1}, limit: 100});
});

// lib/router.js
FlowRouter.route('/crew/:crewSlug', {
    subscriptions: function(params) {
        console.log("Subscribed to this crew's chat messages:", params.crewSlug);
        this.register('crewMessages', Meteor.subscribe('crewMessages', params.crewSlug));
    },
    action: function(params) {
      FlowLayout.render("layout", { content: 'crew' });
    }
});

そして私のcrew.htmlテンプレート内:

<div class="container">
  {{> crewChat}}
</div>

そして私のcrewChat.html/js

Template.crewChat.helpers({
  messages: function() {
    return CrewMessages.find({}, {sort: {submitted: -1}}); 
  }
});

<div class="ui feed">
  {{#each messages}}
    {{> crewChatMessage}}
  {{/each}}
</div>

私のcrewChat.jsファイルでは、Flow-router で設定したサブスクリプションをどのように使用できますか?

4

1 に答える 1