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


#1

/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?


#2

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.


#3

What prob do you have exactly?


#4

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:


#5
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


#6

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


#7

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


#8
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?


#9

No. It’s only for the initial route.


#10

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