Why Angular added signals

Signals showed up as a developer preview in Angular 16, and with 17 signal() and computed() are stable.

Signals showed up as a developer preview in Angular 16, and with 17 signal() and computed() are stable. It’s easy to see them as “Angular copying everyone else”, but they solve a specific problem Angular has had since the beginning.

The problem: Angular doesn’t know what changed

With Zone.js, Angular finds out that something happened: a click, a timer, an HTTP response. It doesn’t find out what changed. So it checks every component, top to bottom, and compares every binding with its previous value.

OnPush narrows that down, but it’s coarse. A component is either skipped or fully checked, and it relies on you following the rules about immutable inputs and markForCheck().

A signal is a value that knows who reads it. When it changes, Angular knows exactly which templates depend on it. That’s the piece that was missing.

The three building blocks

import { computed, effect, signal } from '@angular/core';

const count = signal(0);           // a value you can set
const double = computed(() => count() * 2); // derived from other signals

effect(() => {
  console.log('count is', count()); // runs again whenever count changes
});

count.set(5);
count.update((c) => c + 1);

You read a signal by calling it, like count(). That call is how Angular tracks dependencies. Inside computed or a template, every signal you read becomes a dependency automatically. There’s no dependency array to keep in sync.

computed is lazy and cached. It only recalculates when one of the signals it read has changed, and only when someone actually reads it.

If you tried the v16 preview, note that mutate() is gone in 17. Use update() and return a new value.

A small store

This is where signals have been nicest for me so far, replacing a BehaviorSubject service:

@Injectable({ providedIn: 'root' })
export class CartStore {
  private items = signal<CartItem[]>([]);

  readonly list = this.items.asReadonly();
  readonly count = computed(() => this.items().reduce((n, i) => n + i.qty, 0));
  readonly total = computed(() =>
    this.items().reduce((sum, i) => sum + i.price * i.qty, 0),
  );

  add(item: CartItem) {
    this.items.update((items) => [...items, item]);
  }

  remove(id: string) {
    this.items.update((items) => items.filter((i) => i.id !== id));
  }
}

And a component that uses it, with the new @if block from v17:

@Component({
  selector: 'app-cart-badge',
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    @if (cart.count() > 0) {
      <span class="badge">{{ cart.count() }}</span>
    }
  `,
})
export class CartBadgeComponent {
  cart = inject(CartStore);
}

No async pipe, no subscription, no markForCheck(). When a signal that the template reads changes, Angular marks the component for check, even with OnPush. You also don’t get the null from async that you have to handle before the first value arrives, because a signal always has a value.

effect() is for side effects only

effect is still in developer preview in 17, and it’s the easiest part to misuse. It’s meant for syncing with things outside Angular’s data flow: localStorage, a chart library, logging.

constructor() {
  effect(() => {
    localStorage.setItem('cart', JSON.stringify(this.cart.list()));
  });
}

If you find yourself setting one signal inside an effect based on another, you almost always want computed instead. Angular nudges you here: writing to a signal inside an effect throws an error unless you pass { allowSignalWrites: true }. That’s on purpose.

Effects need an injection context, so create them in a constructor or field initializer. They’re cleaned up when the component is destroyed.

Signals and RxJS

Signals don’t replace RxJS. They’re good at holding state. Observables are still better at events over time: debouncing, cancelling requests, combining streams. The interop helpers in @angular/core/rxjs-interop connect the two (they’re still in developer preview):

// Observable to signal
seconds = toSignal(interval(1000), { initialValue: 0 });

// signal to Observable, e.g. to use switchMap
userId = signal('1');
user = toSignal(
  toObservable(this.userId).pipe(
    switchMap((id) => this.http.get<User>(`/api/users/${id}`)),
  ),
);

The pattern I’ve ended up with: RxJS for the async plumbing, toSignal at the edge, and signals in the template.

Where this is going

Right now signals live alongside Zone.js and the usual change detection. Inputs are still @Input() decorators, so you bridge them with a setter if you want a signal. But the Angular team has said openly that signals are the path to apps that don’t need Zone.js at all, with change detection driven only by what actually changed. Starting with stores and new components is a good way to be ready when that arrives.