kadirahq / fast-render

Render you app even before the DDP connection is live. - magic?
MIT License
560 stars 80 forks source link

Routes with params and reactivity with template level subscriptions #180

Open squarfed opened 7 years ago

squarfed commented 7 years ago

How should one use fast render when the route has parameters? I have this code in the lib folder:

 FlowRouter.route('/articles/:articleId', {
   action: function() {
      // The template 'article' runs the following subscription:
      //      this.subscribe('singleArticle',articleId)
       BlazeLayout.render('website', {content: 'article'});
   }
 });

 if (Meteor.isServer) {
   FastRender.route('/articles/:articleId', function(params) {
     console.log('params: ',params)
     this.subscribe('singleArticle', params.articleId)
  })
}

However the FastRender.route code does not run again when you go to a route with a different article_id. I tried using:

 Tracker.autorun( () => {
      FlowRouter.watchPathChange()
      console.log('params: ',params)
      this.subscribe('singleArticle', params.articleId)
    })

But watchPathChange is not defined on the server...