Post

tried writing this blog 3 times but it’s really boring, so here’s the short version: React won. Every mainstream f/w now implements its ideas, and developed their own ecosystems. The ones that didn’t, lost and died. This implies there’s no _strong_ reason to not pick one of the other winners.

Without a compiler, and with the virtualized DOM paradigm, I don’t really know that react is in a great position to benefit from signals. Frameworks that use compilers and “templated“ DOM (including JSX usage) will always have an advantage using any reactive primitive for targeted updates

Put differently, if we react has to build an object tree, and then diff it against another object tree in order to know what to update, then targeted updates aren’t really on the table. And reactive types like signals really don’t have any direct advantage for react.

Any insight into why you'd roll your own at this point? Preact's is agnostic, fast, small and sel contained...

0 reposts10 likes

Admittedly the things I was looking for was: - Small (Preact's got) - No auto tracking (explicitness in library code) - Any side effects being "mountable" and unmountable (namely for React support) - Ability to diff new vs previous values so we can keep referencial stability between computations

To be clear: absolutely not against using someone else's signals implementation if it ticks those boxes. (Or even wrap our own) The "Store" implementation is probably really bad, given I have written it naively (hard to find non-whitepaper reading on topic)

Tbh preact's does tick all of those. It might be worth a try. It's also entirely free of memory bookkeeping - you never have to worry about destroying or cleaning up state, as it's all left to the JS engines garbage collector.

For your case, it sounds like you would just use the .subscribe() method on signals. Benefits would be the graph optimizations, battle-testedness and size. Also interop! Our signals are valid Svelte Stores.

no auto tracking I've been exploring this idea for years and always come up empty handed I don't know how to make this ergonomic and practically useful any idea what you'd want this to look like in terms of usage? 🙂

okay, yeah, as an add-on for existing frameworks where I get stuck is how do we design a framework where something like this is the fundamental state management primitive a unified model both for component state and shared state the core principle, not an afterthought 🙂