EugVal
EugVal

Reputation: 233

How to reload when a route parameter changes with Meteor FlowRouter?

I am using Meteor and FlowRouter, and I would like to force my page to reload when I change the url (or alternatively one of the parameters of my route). Would anyone know a way to do so?

There has been a few debates over this, but I haven't found a satisfactory answer yet.

PS: I know one suggested method is to put FlowRouter.watchPathChange() inside a Tracker.autorun() but this doesn't seem very satisfactory for what I want to do (changing css classes based on the route parameter), plus I'd like to have the effect of having a page reload.

Upvotes: 1

Views: 581

Answers (1)

Ramil Muratov
Ramil Muratov

Reputation: 546

FlowRouter has a few reactive APIs for accessing the URL state very efficiently:

  • FlowRouter.getParam("paramName")
  • FlowRouter.getQueryParam("queryParamName")
  • FlowRouter.getRouteName()

FlowRouter guide

Putting FlowRouter.watchPathChange() inside a Tracker.autorun() is not the only option. You can put in autorun some of functions listed above.

Upvotes: 1

Related Questions