Menu

Still Playing Catch-Up: A Look at Solid 2
πŸ“°

Still Playing Catch-Up: A Look at Solid 2

DEV Community: frontendΒ·Kirill NovgorodtsevΒ·18 days ago
#T2AA9A0r
#devtofrontend#devto#dev#enter#exit
Long article (1883 words) β€” no AI summary yet.
Reading 0:00
15s threshold

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 .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.