Solid 2 brings a new reactivity system. In the announcement , Ryan Carniato writes:
Today signals are everywhere.
Well, let's see how it turned out.
Benchmarks
We'll use this benchmark to test how well each implementation avoids unnecessary work in a dependency graph.
Here's what the graph looks like.
C β A, B D β A, B E β C, A, D F β D, B G β C, E (only if C is falsy), D, F H β G I β G J β F
Enter fullscreen mode
Exit fullscreen mode
A and B are the inputs. The expression that exposes unnecessary computation is G = C() + ( C() || E()%2 ) + D()[4].x + F() . When C() is truthy, G never reads E , so there's no need to evaluate it for G .
Here's the Solid 2 benchmark code.
const [ A , setA ] = createSignal ( 0 ) const [ B , setB ] = createSignal ( 0 )
createRoot ( ( ) => { const C = createMemo ( ( ) => ( A ( ) % 2 ) + ( B ( ) % 2 ) ) const D = createMemo ( ( ) => numbers .β¦