Preact Signals just got a huge performance boost: Signals rendered as text/props & effects only "pull" as fast as needed for rendering. Since computeds run as-needed, they now only re-run as often as their downstream DOM output can be painted. H/t to @jovidecroock.com for making this happen.
Post
The really awesome thing is, this effectively brings the value of scheduling to signals without any of the headaches normally associated with scheduling: Because it's not possible to bog the graph down by computing state for outdated frames, it's able to begin computing on every frame instantly.
2 reposts21 likes
This is possible because Preact Signals uses a two-phase design: changing a signal _notifies_ its dependencies that they need to recompute (top-down), but recomputation is only performed when each dependency's value is accessed (bottom-up). All we have to do is intelligently schedule the leaf reads!