kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 192 forks source link

possible timing error when adding params to a route #377

Open kjetilge opened 9 years ago

kjetilge commented 9 years ago

The problem: In a template with an html5 embedded video, the source url is generated with a helper. If I hard code the helper and have a route without params my video loads. If I add params to the route, the video is not loaded, but the generated source url is correctly generated.

I have a route like this:

FlowRouter.route('/videoplayer', {
    action: function(params, queryParams) {
      BlazeLayout.render('player', {
        videoArea: "html5Player",
        videoNavArea: "videoNav"
      });
    }
});

With a hardcoded helper:

Template.html5Player.helpers({
  video: function () {
    return {_id: "F6cmExoGDPo2CCxPa", fileName: "v5.mp4"}
  }
})

a subscription:

Template.html5Player.created = function() {
  var self = this;
  self.autorun(function() {
    self.subscribe('videos');
  });
}

And a simple jade template

template(name="html5Player")
  if Template.subscriptionsReady
    video(id="video" controls="controls" preload="auto")
        source(type="video/mp4" src="video/{{video.fileName}}")

So if I change the route to

FlowRouter.route('/videoplayer/:videoId'

and use some arbitrary id, the video stops loading. I believe that this is inconsistent behavior, maybe a timing error ? Any idea what to do about this ?

For now I use queryParams instead.

arunoda commented 9 years ago

Since you are not using any FlowRouter specific code, it should not re-render. If so, that's an error. Could you isolate this case into a simple repo, where I can try to run this locally?