Skip to content
FrontDepth, Home

2021 – today

Signals and fine-grained reactivity

Values that know who reads them: each effect updates exactly the DOM it depends on, without re-running a component.

MiddleSeniorRuns on: Preact Signals 1.14.5

The problem

Component frameworks re-run a whole component when its state changes. React calls the component function again and compares the output; Vue re-runs the component's render function and compares the new virtual DOM tree with the old one. That is usually fast enough, but the work is done per component, not per change: ticking one checkbox re-renders the whole component that owns the list, and in React keeping that cheap is your job, with memo, useMemo and dependency arrays.

The idea

A signal is a value that knows who reads it. A computed derives a value from other signals and caches it; an effect runs once, records every signal it read and runs again only when one of them changes. Give each changing piece of the DOM its own effect, and an update touches exactly those nodes: no virtual DOM, no component re-run. When a computed comes out the same as before, nothing after it runs.

Knockout's observables did this in 2010. Solid built a whole framework on it; today Preact, Angular and Svelte 5 have signals too, and Vue's docs call its refs the same kind of primitive. Here every todo's done is a signal of its own: ticking one re-runs that row's effect and the counter's, and nothing else.

What hurt next

Signals are not part of JavaScript yet. The TC39 proposal reached Stage 1 in April 2024 and is still there; it aims at a shared core that frameworks can build on, not at an API for apps, and leaves effects out on purpose. Until then each framework has its own signals with its own API (.value in Preact and Vue, count() in Angular and Solid), and state written for one does not plug into another.

Automatic tracking can surprise, too: an effect depends only on the signals it read during its last run, so a signal read behind an if that was false, or later in a callback, is not tracked. Effects also have to be disposed when their part of the page goes away; this demo never removes a todo, so it never has to.

The newest era on the timeline.

How close this is to the original

Runs @preact/signals-core 1.14.5 (October 2026), the core of Preact Signals with no dependency on Preact itself; signal, computed and effect have been there since 1.0 (September 2022). The DOM code is written by hand. In Solid, Preact or Angular you rarely write such effects yourself: the framework tracks the signals read in JSX or a template and updates the DOM for you. The demo spells out what those bindings do.

The todo app in this era