question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Waiting on Meteor Method data, with Flow-Router SSR and Fast-Render

See original GitHub issue

This is a complex issue but I’ll try to describe it. With collection data, we have the following flow when we make a new request:

  • Simulate the subscription in React Komposer on the server.
  • Flow-Router SSR gets the data on the server and generates markup.
  • Show SSR-generated markup.
  • Fast-Render gets the data on the server and injects it in the document.
  • Subscribe instantly in React Komposer on the client.
  • Show app.

This means that when the user loads the app, A) the page is immediately populated with the server-generated markup and B) Minimongo is immediately populated with the fast-render generated data. So (if I’m not mistaken) Meteor.subscribe('posts').ready() in React Komposer will always return true on first load, and that’s what we’re not seeing any loading screens when using Flow-Router SSR.

Now if the data is instead coming from a method, this doesn’t quite work as well. Let’s say that you have a single value stored on the server you want to make available to your whole app before it’s loaded (in my case, the server timezone).

First of all Meteor.call is not reactive, so we have to use reactive method instead.

But even so, we have the issue that there is no Fast-Render equivalent for methods or arbitrary variables. So if we want to wait for the result of this method, we can’t bypass our “loading…” screen, which defeats the point of having SSR in the first place.

In other words, with a method the flow becomes:

  • Simulate the method call in React Komposer on the server.
  • Flow-Router SSR gets the method data on the server and generates markup.
  • Show SSR-generated markup.
  • Subscribe in React Komposer on the client.
  • Show loading. (bad!)
  • Subscription is ready
  • Show app.

I’m not sure how I can get around this, apart from not using methods at all… Any ideas?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
SachaGcommented, Jun 23, 2016

FlowRouter SSR will inject two things:

  1. the HTML markup
  2. the initial collections data (via fast-render)

My use case was that I needed to access some other arbitrary piece of dynamic data that was not stored in a collection. So it’s different from the issue you refer to, which concerns collection data.

0reactions
sahanDissanayakecommented, Jun 23, 2016

Right. Ok thanks… I knew 30% my issue would be different.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does fast-render have no effect in React projects using Flow Router ...
In my React apps, all my subscriptions are handled at the component level: getMeteorData() { const handle = Meteor.subscribe('myData'); return { ready: ...
Read more >
meteorhacks:flow-router-ssr - Packosphere
Carefully Designed Client Side Router for Meteor. Flow Router is a minimalistic router which only handles routing and subscriptions. You can't have any...
Read more >
flow-router/README.md at master - GitHub
FlowRouter is a very simple router for Meteor. It does routing for client-side apps and does not handle rendering itself. It exposes a...
Read more >
FlowRouter SSR is almost ready - Medium
FlowRouter SSR will bring Server Side Rendering (SSR) to Meteor, ... SSR, we can render pages very quickly and do not need to...
Read more >
Using FlowRouter SSR with meteor and get the connection ...
// Routes.jsx FlowRouter.route('/my-route', { action(params) { params.auth = false; if (Meteor.isServer) { params.auth = Meteor.call('authMethod ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found