I’m at the point where I’m wondering if choosing Svelte for NodeKit is a design error in terms of cultural fit and goals. (They want to be the “serverless” framework for Big Tech. I feel like I’m hitting my head against a wall whenever I want to adapt anything for small web use because it’s all geared towards corporate web use.)

Anyone here played with htmx and hyperscript? Any experience with the community?


Question to JavaScript folks who have experience with Node.js… how does the following (theoretical) code listing for a server-side route that renders an index page with a count that’s persisted in memory on the server and updated any time someone loads the page read to you?

Re: javascript 

@aral my first intuition would be that this always displays 1, because let count = 1 is on the top of the file, and it looks like it always gets executed when the page is rendered :blobfoxglare:

I’d expect a clearer separation between the initialization and the rendering, like

let count = 1; export default function render() { return <div>{count++}</div>; }

or maybe even (goodness forbid!)

let count = useState(1); return <div>{count++}</div>;

(btw, won’t the code display 1 times even on the first request, because the condition count > 1 gets evaluated after the post-increment? granted, I’m not familiar with the order of side-effects in jsx interpolation expressions)


Re: javascript 

@kristof Thanks, Kristóf. Interestingly, that’s exactly how I have it in NodeKit right now :)

· · Web · 0 · 0 · 1
Sign in to participate in the conversation
Aral’s Mastodon

This is my personal Mastodon.