react

"mulling over state management stuff"
orestis 2020-12-22T06:51:49.070200Z

>Can this be run in any other back end other than Node since it only transmits a stream of serialized vdom? React components themselves are JS so we'd expect the backend to be in JS. (I mean, you could reimplement it in Rust or something, but then you can't easily move components to the Client and back.) There is no hard dependency on Node.js itself — as long as your JS environment has some sort of streams, we could make it work.

orestis 2020-12-22T06:52:02.070400Z

From https://news.ycombinator.com/item?id=25500544

orestis 2020-12-22T06:52:56.071100Z

Perhaps with hiccup we could make it work sans JS

lilactown 2020-12-22T07:08:06.072100Z

i think something more like React elements would be a good general lib in Clojure 🙂 but hiccup could compile to it

lilactown 2020-12-22T07:08:48.072700Z

(defrecord Element [type props key])

dominicm 2020-12-22T07:43:17.073300Z

I think the hard part would also be coming up with a stream api

dominicm 2020-12-22T07:43:55.074300Z

Would you have the clojure code write progress to a core async channel?

dominicm 2020-12-22T07:44:52.075100Z

They're doing something funky (concurrent mode?) To make that stream

orestis 2020-12-22T08:16:23.075800Z

Well they’re using Suspense and Concurrent mode to also make the async stuff look synchronous, so that React can move on to render other bits and stream them.

orestis 2020-12-22T08:17:12.076600Z

TBH, it looks to me that this is some complex machinery for an often talked about, but kind of niche use case.

lilactown 2020-12-22T18:31:10.078100Z

I assume they're using either websockets or a streaming HTTP response

lilactown 2020-12-22T18:31:57.078800Z

so we'd want to use whatever Clojure solution solves that problem

lilactown 2020-12-22T18:32:26.079200Z

using core.async, manifold, etc. seems like an implementation detail

lilactown 2020-12-22T18:33:21.079800Z

you're right though that replicating their machinery for suspending on the server will be difficult

dominicm 2020-12-22T23:05:52.079900Z

I'm thinking more about what that actually looks like. I know they throw a promise and then retry later under the hood, and we could do that. But it still feels weird.

dominicm 2020-12-22T23:05:55.080Z

Maybe a go-like macro :P