untangled

NEW CHANNEL: #fulcro
tony.kay 2017-01-03T01:37:21.001600Z

@sova The way you'd do server side rendering (IMHO) is to create a simple tree of initial data, a root react factory, and just call that and pass the result to render-to-string. No parser needed in Om or Untangled. The use of Untangled's InitialAppState technique would be quite useful for generating exactly what you want in this case.

tony.kay 2017-01-03T01:39:01.001601Z

@danielgrosse Each component to go on the screen is composed into a React vdom rendering tree. The queries are the same: each component's query composes in the immediate child queries, just like each component's render composes in the child components via render. When I say top-level properties, I'm typically referring to the properties queried at the root of the UI tree.

sova-soars-the-sora 2017-01-03T01:43:33.001602Z

@tony.kay ah cool, thanks a lot for sharing your thoughts. i'm trying to see what the "tree of initial data" looks like .. is it an atom? coming from js/json i'm trying to find the clojure equivalent of json arrays...

tony.kay 2017-01-03T01:44:05.001603Z

It's just a nested data structure

tony.kay 2017-01-03T01:44:30.001604Z

{ :root 1 :child {:x 2 :subchild { ... }}}

tony.kay 2017-01-03T01:44:49.001606Z

to go with a nested UI Root renders Child which render Subchild

tony.kay 2017-01-03T01:46:25.001608Z

in that section of the devguide you can see the queries, initial app state, and rendering all composing together

tony.kay 2017-01-03T01:48:45.001611Z

The video is probably a good way to get a feel for it.

tony.kay 2017-01-03T01:50:01.001612Z

Another nice thing about Om/Untangled: There is only Clojure(script) and EDN (extensible data notation...the data language of clojure itself). No javascript. No JSON. Everything is unified.

tony.kay 2017-01-03T01:50:43.001615Z

well, and since it is react: no html (of consequence) either

sova-soars-the-sora 2017-01-03T01:58:50.001616Z

Yo! Thank you so much. It's satisfying to know that I'm gradually coming to the same conclusions for design and project layout as greater minds before me have.

tony.kay 2017-01-03T01:59:41.001617Z

We've generated a lot of docs/videos. Trying to make it easy to get going 😉

sova-soars-the-sora 2017-01-03T02:29:42.001618Z

Rock on. If my initial state is provided by Datomic, I can just do some server-side queries to get the initial load... is that the easiest way?

tony.kay 2017-01-03T02:30:34.001619Z

Sure. Graph queries on Datomic do return trees of data. They may not align with your UI perfectly, so you usually will have to massage them a bit

tony.kay 2017-01-03T02:31:05.001620Z

In that case you would not use InitialAppState at all...just make the tree and pass it to a render of the root

tony.kay 2017-01-03T02:31:16.001621Z

(def ui-root (om/factory Root))

tony.kay 2017-01-03T02:31:28.001622Z

(dom/render-to-string (ui-root initial-tree-of-data))

tony.kay 2017-01-03T22:18:21.001639Z

Hey all. I just finished a preliminary version of server-side rendering and pushed it to untangled-client on clojars as 0.6.2-SNAPSHOT

2
tony.kay 2017-01-03T22:18:33.001640Z

There is a spec (server-rendering-spec) that shows the usage

tony.kay 2017-01-03T22:18:59.001641Z

There are some gotchas: You cannot call protocols on a defui component directly in clj. So, I made a get-initial-state function.

tony.kay 2017-01-03T22:19:18.001642Z

If you're using (ident) or (query) directly in your code it won't work.

tony.kay 2017-01-03T22:19:24.001643Z

this is an Om limitation, not Untangled

tony.kay 2017-01-03T22:20:06.001644Z

This is NOT on develop yet. The source is on a (published) branch on github: feature/server-side-rendering