~/dev.log

cd ..

Mastering Signals: Why Angular Won the Reactivity War

2025-11-15•#Reactivity#Performance#Angular

A deep dive into fine-grained reactivity and why it leaves React hooks in the dust.

Reactivity is the heart of modern web development. For years, we've relied on Zone.js in Angular or the useState/useEffect dance in React. But with the introduction of Signals, Angular has fundamentally shifted the landscape. In my opinion, it offers a far superior developer experience to React's current model.

The Problem with "Effect" Dependencies

If you've written React, you know the pain:

// React: The "Dependency Array" Game
useEffect(() => {
  doSomething(data);
}, [data, doSomething]); // Forgot one? Infinite loop or stale closures.

In React, you are manually responsible for telling the framework when to re-run your logic. It's fragile, prone to bugs, and often leads to over-rendering the entire component tree only to diff it against the DOM.

Enter Angular Signals

Angular Signals (inspired by SolidJS) flip this model. You don't tell the framework when to update; you simply define what the data is. The usage is the dependency.

// Angular: Reactive Primitive
count = signal(0);
double = computed(() => this.count() * 2);

// Auto-updates only when count changes. No arrays. No guessing.
effect(() => {
  console.log(`Count is ${this.count()}, double is ${this.double()}`);
});

Reducing Cognitive Load

The biggest win isn't performance (though that's great). It's the massive reduction in cognitive load.

When writing React hooks, a significant portion of your brain power is dedicated to managing specific synchronization details:

  • "Is this object stable or do I need useMemo?"
  • "Did I miss a dependency in useEffect?"
  • "Why is this effect firing twice?"

This is "invisible tech debt" that you pay every time you touch a component. Use Signals, and that debt vanishes.

Maintainability by Default

With Signals, the code describes the relationship between data, not the synchronization mechanism.

  • Declarative vs Imperative: computed(() => a() + b()) is a fact. useEffect(() => setC(a + b), [a, b]) is an instruction. Facts are easier to maintain than instructions.
  • Local Reasoning: You can look at a Signal and know exactly how it derives its value without scanning the file for side-effects that might update it.
  • Refactoring Safety: Moving logic around doesn't break reactivity chains because the dependencies are tracked automatically.

Signals vs. RxJS

I still love RxJS for complex asynchronous streams (websockets, debounced search), but for synchronous state management, Signals are the clear winner. They remove the need for BehaviorSubject boilerplate and the dreaded async pipe null checks in templates.

Making the switch isn't just about performance—it's about writing code that is easier to read, easier to test, and harder to break.