A deep dive into the internal mechanics of Signals, specifically the push-pull based algorithm that powers fine-grained reactivity in modern JavaScript frameworks like Solid, Vue, Preact, and Angular. The push approach eagerly propagates invalidation notifications down the dependency graph, while the pull approach lazily re-evaluates computed values only when they are read and marked dirty. The post walks through implementing a minimal Signal system from scratch, explaining auto-tracking of dependencies via a global STACK, cache invalidation using a dirty flag, and how computed values clean up and re-establish dependency links on each recomputation. Also touches on the TC39 proposal to standardize Signals natively in JavaScript.
Sort: