[solved] FastRender doesn't work when changing route or following a link

/lib/router.coffee

FlowRouter.route "/addPost", action: ->
	BlazeLayout.render "addPost"

/server/addpost.coffee

FastRender.route '/addPost', ->
	this.subscribe('prices') 

When I use FlowRouter.go('/addPost') or a link to '/addPost' the prices data isn’t there.
Same happens if I ‘go back’ to '/addPost' from another route via Back browser button.

At the same time if I open the link in new window (ctrl+click) or go to localhost:3000/addPost manually in new tab, or refresh not working localhost:3000/addPost with F5 - everything works ok.

What am I missing here?

1 Like

I have the same problem, but even without using fast render… so i think it’s not FastRender related and more some missusage of flow router.

What prob do you have exactly?

FastRender is only about speeding up the initial page load. If you want to keep the data around between page transitions, you should look at SubsManager by the same author:

1 Like
FastRender.route '/addPost', ->
	this.subscribe('prices')

I can’t understand coffeescript well. But I assume there is something wrong here. You need to subscribe inside the subscriptions method.

See: https://github.com/kadirahq/flow-router#fast-render

Sorry i just reread your question and figured out, that your problem isn’t that similar as it seemed to be - so i opened another topic: [solved] FlowRouter.go() problems

No, no, no! FastRender is about rendering data on every route.

FastRender.route '/addPost', ->
	this.subscribe('prices')

equals

FastRender.route('/addPost', function() {
  return this.subscribe('prices');
});

And this is standard FastRender api

It’s strange that you recommend use subscribtions method - you were always an advocate of template-level subscriptions, no?
And I don’t subscribe inside client code at all because I fetch my data through methods. But I need some data to be initially available with FastRender.
Could you advise something?

No. It’s only for the initial route.

Ah, that explains it… I’ve designed my app, thinking the contrary :astonished: Will have to change some data logic now…