Waiting on Meteor Method data, with Flow-Router SSR and Fast-Render
See original GitHub issueThis 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:
- Created 7 years ago
- Comments:8
Top GitHub Comments
FlowRouter SSR will inject two things:
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.
Right. Ok thanks… I knew 30% my issue would be different.