kadirahq / flow-router

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

No fine-grained reactivity on parameters in grouped route prefixes #194

Open rclai opened 9 years ago

rclai commented 9 years ago

If grouped route uses a param in the prefix, changing to a different route in the same group should not trigger invalidation on that param again.

var group = FlowRouter.group({
  prefix: '/group/:_id'
});

group.route('/a', {
  name: 'a'
});

group.route('/b', {
  name: 'b'
});

Tracker.autorun(function (c) {
  console.log('_id:', FlowRouter.getParam('_id'));
});

var id = 'test';
FlowRouter.go('a', { _id: id });
FlowRouter.go('b', { _id: id });
arunoda commented 9 years ago

I didn't check this but following code seems pretty wrong to me.

Tracker.autorun(function (c) {
  if (! c.firstRun) {
    console.log('_id:', FlowRouter.getParam('_id'));
  }
});

So, in the firstRun it won't see getParam(). So, there won't be any re-runs. Try to put it before if.

rclai commented 9 years ago

Oh, right. I just did that just so you didn't see it be undefined on the first run, but I guess you understand.

arunoda commented 9 years ago

I'll have look at this.

rclai commented 9 years ago

Thanks.

arunoda commented 9 years ago

@delgermurun did we support params in the prefix?

rclai commented 9 years ago

It does work, thanks to this. There's no tests for it though.

arunoda commented 9 years ago

Ah! Now I got it. Oh! didn't read the title at all. Sounds like a good call. Let's see what's going on here.

rclai commented 9 years ago

I think I made the title too long haha.

arunoda commented 9 years ago

We need TLDR for titles as well :P

rclai commented 9 years ago

Okay, this title is better :smile:.

arunoda commented 9 years ago

ha ha :D

arunoda commented 9 years ago

@rclai This involves a lot of things than it seems. This involves major refactor. So, I'm deferring this for 3.0 I hope that's okay.

rclai commented 9 years ago

I figured it would, no problem.