0Pricing
Angular Academy · Lesson

Effects and Side Effects

React to signal changes with effects.

What is an Effect

An effect() runs a function whenever any signal it reads changes. Unlike computed, effects are for side effects: logging, syncing to localStorage, calling APIs, manipulating the DOM.

Effects do not return a value.

Creating an effect

An effect runs once immediately, then re-runs every time a tracked signal changes.

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

const count = signal(0);

effect(() => {
  console.log('count is', count());
});
// logs "count is 0" immediately
count.set(5); // logs "count is 5"

All lessons in this course

  1. Computed Signals
  2. Effects and Side Effects
  3. Effect Cleanup and Lifecycle
  4. linkedSignal and Advanced Patterns
← Back to Angular Academy