AI summary by TwinMind
If this ships, it will change javascript forever
Theo - t3․gg
25m 53s
Proposal Overview
- TC39 proposal for native JavaScript signals in stage 0 (earliest stage)
- Written by Eisenberg Effect, seeking stage 1 consideration by Daniel Ehrenberg (Bloomberg) and Jan from Google
- Spec-compliant polyfill available for immediate use (with disclaimer not for production)
- Push-then-pull algorithm with acyclic graph data structure
Contributors & Industry Support
- Daniel Ehrenberg: Major tc39 contributor at Bloomberg
- Dominic Gannaway: Former React core team, now at Vercel working on Svelte
- Michael Weststrate: Creator of MobX, introduced patterns now widely adopted
- Ben Lesh: Creator of RxJS, standardized signals concept in JavaScript
- Patrick JS: Notable developer ("accidentally killed npm")
- Frameworks providing input: Angular, Bubble, Ember, Fast, MobX, Preact, Qwik, RxJS, Solid, Starbeam, Svelte, Vue, Whiz
Signal Fundamentals
- Data type enabling one-way data flow modeling cells of state and computations
- Forms acyclic graph where nodes derive state from sources and contribute to sinks
- Nodes tracked as clean or dirty for efficient updates
- Counter example:
const counter = new Signal.State(0), access viacounter.get(), update viacounter.set(1) - Computed signals:
const isEven = new Signal.computed(() => counter.get() % 2 === 0)
Push-Then-Pull Algorithm Advantages
- Automatic memoization: No recomputation if source values unchanged
- Lazy evaluation: Unneeded values not recomputed even when sources change
- False update avoidance: Counter changing 2→4 won't trigger parity recomputation since isEven result identical
- Dirty flag propagation: Changes push dirty flags through graph, computation delayed until value explicitly pulled
API Design Philosophy
- Two user categories: Application developers vs Library/Framework developers
Signal.StateandSignal.computedfor app devs in main namespaceSignal.subtlenamespace for framework authors (advanced/dangerous APIs)Signal.subtle.WatcherSignal.subtle.untrack- Introspection APIs
- Effect API deliberately excluded - too framework-dependent for standardization
Browser Implementation Benefits
- Native browser optimizations possible vs polyfills
- Memory assignment optimizations
- Performance improvements through native runtime integration
- Smaller bundle sizes (no JS shipping needed)
- Framework interoperability: React, Svelte, Solid components sharing same state model
Library Integration Approach
- First step: Replace library-specific signal implementations with
Signal.State/Signal.computed - Custom effect implementations using
Signal.subtleprimitives - Microtask queue batching example provided
Signal.subtle.untrackfor preventing unwanted graph connections during framework rendering
Use Cases & Examples
- Counter class implementation with signals
- Decorator pattern:
@signalaccessor decorator - Array rendering optimization using
untrackto prevent false dependencies - Solid.js integration example (modified for proposed standard)
Current Status & Next Steps
- Stage 0: Not yet under formal tc39 consideration
- Seeking stage 1 in coming weeks
- Slow, prototype-driven approach
- Community involvement encouraged through GitHub
- Testing, reporting other implementations, examples needed
