Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How Angular Signals work under the hood?

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

How Angular Signals work under the hood?

Avatar for Rohtash Sethi

Rohtash Sethi

June 02, 2025

Other Decks in Programming

Transcript

  1. About Me... 👨‍💻 10+ years of experience in Angular 🌟

    Senior Principal Software Engineer at Secureworks (Sophos) 🎙️ Founder of NG Delhi Community 📚 Angular Content Creator
  2. Angular Signal A lightweight wrapper around a value set read

    notify Signal as Producer Comsumer 1 const counter = signal<number>(1); counter.set(2); counter.update(count => count + 1); counter() Example 1 (basic)
  3. Under the hood const counter = signal(1); let double =

    computed(() => counter() * 2); console.log(double()); // 2 double = null; Example 2 (with computed)
  4. Under the hood Dependency Graph of Reactive Nodes After assigning

    null to the double holding a computed signal
  5. ▶️ Phase 1: Push 🔁 Phase 2: Pull Angular Signals

    use the push/pull algorithm 1.sum() is dirty → so it asks for double() 2.double() is dirty → so it recomputes using the new count = 2 → double = 4 3.Now sum = 2 + 4 = 6 ✅ 1.count changes → it notifies all its dependents (double, sum) 2.These are marked dirty but not re-evaluated 3.effect is also marked dirty but not run ⏳ Nothing is recomputed yet.
  6. Signal APIs For improved Developer Experience Parent/Child Interaction State Management

    signal (writable) computed (readonly) input (readonly) output model (writable) RxJS Interoperability toSignal toObservable Signal based queries viewChild & viewChildren contentChild & contentChildren effect (side effect) linkedSignal (writable) Output EventEmitter Interop outputFromObservable outputToObservable From v20, all Signal APIs are stable :)