News for hackers. Stuff that matters.
Re:Svelte 5: Runes by satvikpendem on Wednesday September 20, 2023 @11:27AM (#37585430)
React is honestly how I used to write my code in jQuery too, for some pages that had a lot of state. Basically, just like in game dev, I had a render() function that I'd call at the end of the file that would re-render everything. The pattern itself is very easy to understand, re-rendering efficiently is the hard part, but for React users today, that's an implementation detail.

Hooks are also very interesting, they're basically functions that run at specific times, or that is to say, they're `f(...parameters, state)`. They hold state inside the function, sort of like a closure.

Re:Svelte 5: Runes by bafe on Wednesday September 20, 2023 @04:04PM (#37589386)
Indeed, seeing hooks as closures helped me to understand how they are use for state management. It's really a "poor man's object" with all the advantages of FP in terms of reasoning about state changes, lack of side effects etc.
Re:Svelte 5: Runes by truetraveller on Wednesday September 20, 2023 @08:13PM (#37591727)
Same here. For complex UIs, I almost always had my own 'render()' function.