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.
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.