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
In the video, a signal containing the mouse coords is used to compute thousands of positions that are applied to thousands of elements as CSS in an Effect. In 1.x, when the rate of input exceeds screen refresh rate, computations run more often than their results can be painted. In 2.x, they don't.
0 reposts15 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!