Closed stolinski closed 7 years ago
Pub/sub always starts when the client side app has booted. While SSR requires data, used to build up the screen, to be available when creating the HTML payload.
This leads us to 2 use cases:
Meteor.isClient
/ Meteor.isServer
to re-establish reactivity in the client.So what's the process of getting data to a React component, using SSR, without Redux?
Using Flow Router SSR, you changed little in your data flow. There doesn't seem to be a simple way to just grab data the same way you would in client side with this package. Is that accurate, or am I missing something.
You're not missing anything at all.
This project heavily relies on Redux. As this piece of software is usable client and server side, its our core data repository. Observers on cursors are feeding the serve side part of the store, while injected data in the HTML payload feed the initial client rendering and subscription or methods do the reactivity. Removing Redux is feasible though really not an easy task.
FlowRouter SSR was an interesting case. Based on Gadi injectors (inject-initial, if my memory serves me well), Arunoda was monkey patching Meteor.subscribe
to mark every use of it server side. This was allowing him to build up its own data repository. By doing this, client side code was almost identical to server side code. Clever, clever move with unfortunately one huge drawback: API changes. This was the main reason why FlowRouter SSR ended up not working.
There are 2 additional drawbacks to this, to:
If you want, I can invite you in our Slack dev channel. We could see together what's the best course of action for moving your app into the architecture that this package requires.
If you plan on making a LevelUp Tuts out of it, that would surely make a clearer path to our users. You can drop me an email (see my profile page).
And by the way, thanks for the ton of invaluable stuff that you've shared on Youtube 👍
Make perfect sense, thanks for the detailed explanations!
Thank you, I was hoping to add this to my next series however we aren't getting into Redux in it. I might be able to just use it to server render an app shell and just load the data client side.
I'm wondering how to use this with a standard pub/sub flow, without using Redux. The docs don't show any examples using normal Meteor pub/sub. Is it possible?