medium.com 3 min read Original Source

90% of Angular Developers Misuse effect() — Here’s the Fix in 3 Primitive

If you open most Angular Signal codebases today, you will find the same pattern repeated everywhere — effect() calling .set() on another signal. It looks harmless.

It even feels reactive. But it is one of the most common architecture mistakes in Angular right now.

Here is the rule that changes everything:

computed() → derive state automatically, linkedSignal() → derive state that can also be written,

effect() → talk to the outside world only. Once this clicks, you will start deleting effect() calls by the dozen.”

computed() → read-only derived state

  • linkedSignal() → writable derived state
  • effect() → communicate with the outside world

Once you understand this separation, Angular signal code becomes dramatically cleaner.

The Biggest Misunderstanding About effect()

A lot of developers treat effect() like this:

{
this.filteredUsers.set(
this.users().filter(user =>
user.fullName.includes(this.searchTerm())
)
);
});” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

effect(() => {
  this.filteredUsers.set(
    this.users().filter(user =>
      user.fullName.includes(this.searchTerm())
    )
  );
});
effect(() => {
  this.filteredUsers.set(
    this.users().filter(user =>
      user.fullName.includes(this.searchTerm())
    )
  );
});

This pattern feels natural if you come from RxJS — it looks like a subscription reacting to changes. But signals are not streams. Derivations belong inside the graph, not outside it.

But this introduces:

  • duplicated state
  • unnecessary updates
  • extra change detection work
  • synchronization bugs
  • multiple sources of truth

This is not a side effect — it is a derivation. And derivations that live inside effects create duplicated state, synchronization bugs, and multiple sources of truth.

The Correct Mental Model

computed() → Pure Derived State

Use computed() when a value can always be calculated from other signals.

Examples:

  • filtered arrays
  • totals
  • validation state
  • formatted text
  • derived booleans

A computed signal is:

  • cached
  • lazy
  • reactive
  • read-only

Example: Search Filtering

Wrong approach using effect()

<button data-code="members = signal([]);
query = signal('');

visibleMembers = signal([]);
constructor() {
effect(() => {
this.visibleMembers.set(
this.members().filter(person =>
person.username.includes(this.query())
)
);
});
}” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

members = signal<Member[]>([]);
query = signal('');

visibleMembers = signal<Member[]>([]);
constructor() {
  effect(() => {
    this.visibleMembers.set(
      this.members().filter(person =>
        person.username.includes(this.query())
      )
    );
  });
}
members = signal<Member[]>([]);
query = signal('');

visibleMembers = signal<Member[]>([]);
constructor() {
  effect(() => {
    this.visibleMembers.set(
      this.members().filter(person =>
        person.username.includes(this.query())
      )
    );
  });
}

This creates duplicated state.

visibleMembers already depends entirely on two signals.

There is no reason to store it separately.

Correct approach using computed()

<button data-code="members = signal([]);
query = signal('');
visibleMembers = computed(() => {
return this.members().filter(person =>
person.username.includes(this.query())
);
});” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

members = signal<Member[]>([]);
query = signal('');
visibleMembers = computed(() => {
  return this.members().filter(person =>
    person.username.includes(this.query())
  );
});
members = signal<Member[]>([]);
query = signal('');
visibleMembers = computed(() => {
  return this.members().filter(person =>
    person.username.includes(this.query())
  );
});
  1. Cleaner.
  2. Safer.
  3. Faster.

And Angular automatically caches the result until dependencies change.

A Simple Rule That Prevents Bad Signal Architecture

If your effect() contains:

.set()
.set()

or

.update()
.update()

on another signal

Pause.

There is a very high chance you actually want:

  • computed()
  • or linkedSignal()

instead.

When linkedSignal() Becomes the Better Choice

Sometimes derived state must still be writable. This is where linkedSignal() comes in — it works like computed() but allows manual overrides. When its dependencies change, it resets automatically. When the user interacts, it stays at the overridden value.”

The classic example is selected items.

Imagine:

  • you have a list of projects
  • the selected project should default to the first one
  • users can manually change selection
  • but when the list changes completely, selection resets

Many developers implement this with effects.

Usually badly.

Overcomplicated effect() Version

<button data-code="projects = signal([]);

activeProject = signal(null);
constructor() {
effect(() => {
const currentProjects = this.projects();
untracked(() => {
this.activeProject.set(currentProjects[0] ?? null);
});
});
}” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

projects = signal<Project[]>([]);

activeProject = signal<Project | null>(null);
constructor() {
  effect(() => {
    const currentProjects = this.projects();
    untracked(() => {
      this.activeProject.set(currentProjects[0] ?? null);
    });
  });
}
projects = signal<Project[]>([]);

activeProject = signal<Project | null>(null);
constructor() {
  effect(() => {
    const currentProjects = this.projects();
    untracked(() => {
      this.activeProject.set(currentProjects[0] ?? null);
    });
  });
}

Problems:

  • requires untracked()
  • manually synchronizes state
  • easy to create loops
  • difficult to reason about

Proper linkedSignal() Version

<button data-code="projects = signal([]);

activeProject = linkedSignal(() => {
return this.projects()[0] ?? null;
});” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

projects = signal<Project[]>([]);

activeProject = linkedSignal(() => {
  return this.projects()[0] ?? null;
});
projects = signal<Project[]>([]);

activeProject = linkedSignal(() => {
  return this.projects()[0] ?? null;
});

Now Angular understands:

  • this signal derives from projects
  • but remains writable
  • and resets automatically when dependencies change

This is exactly what linkedSignal() was designed for.

Multiple Real-World computed() Examples

Example 1 — Form Validation

{
return (
this.email().includes('@') &&
this.password().length >= 8
);
});” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

email = signal('');
password = signal('');

isFormReady = computed(() => {
  return (
    this.email().includes('@') &&
    this.password().length >= 8
  );
});
email = signal('');
password = signal('');

isFormReady = computed(() => {
  return (
    this.email().includes('@') &&
    this.password().length >= 8
  );
});

Example 2 — Shopping Cart Total

<button data-code="cartItems = signal([]);

cartTotal = computed(() => {
return this.cartItems().reduce(
(sum, item) => sum + item.cost * item.count,
0
);
});” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

cartItems = signal<CartItem[]>([]);

cartTotal = computed(() => {
  return this.cartItems().reduce(
    (sum, item) => sum + item.cost * item.count,
    0
  );
});
cartItems = signal<CartItem[]>([]);

cartTotal = computed(() => {
  return this.cartItems().reduce(
    (sum, item) => sum + item.cost * item.count,
    0
  );
});

Example 3 — Dynamic Greeting

<button data-code="currentUser = signal(null);

welcomeMessage = computed(() => {
const user = this.currentUser();
return user
? `Welcome back, ${user.displayName}`
: 'Welcome guest';
});” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

currentUser = signal<User | null>(null);

welcomeMessage = computed(() => {
  const user = this.currentUser();
  return user
    ? `Welcome back, ${user.displayName}`
    : 'Welcome guest';
});
currentUser = signal<User | null>(null);

welcomeMessage = computed(() => {
  const user = this.currentUser();
  return user
    ? `Welcome back, ${user.displayName}`
    : 'Welcome guest';
});

Real Use Cases Where effect() IS Correct

effect() is still extremely important.

But its responsibility is different.

Effects should interact with systems outside Angular signals.

Analytics Tracking

{
analyticsService.track(
'search_changed',
this.searchKeyword()
);
});
}” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

searchKeyword = signal('');

constructor() {
  effect(() => {
    analyticsService.track(
      'search_changed',
      this.searchKeyword()
    );
  });
}
searchKeyword = signal('');

constructor() {
  effect(() => {
    analyticsService.track(
      'search_changed',
      this.searchKeyword()
    );
  });
}

localStorage Sync

{
localStorage.setItem(
'theme-mode',
this.themeMode()
);
});
}” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

themeMode = signal('dark');

constructor() {
  effect(() => {
    localStorage.setItem(
      'theme-mode',
      this.themeMode()
    );
  });
}
themeMode = signal('dark');

constructor() {
  effect(() => {
    localStorage.setItem(
      'theme-mode',
      this.themeMode()
    );
  });
}

Third-Party Chart Library

<button data-code="chartData = signal([]);

constructor() {
effect(() => {
chartLibrary.updateSeries(
this.chartData()
);
});
}” data-toggle-ms=”1200″ aria-label=”Copy code” data-nosnippet=”” class=”code-copy-btn absolute right-3 top-3 size-8 p-1.5 flex items-center justify-center bg-black/50 text-white rounded-md transition-colors duration-200 cursor-pointer hover:bg-black/70″>

chartData = signal<number[]>([]);

constructor() {
  effect(() => {
    chartLibrary.updateSeries(
      this.chartData()
    );
  });
}
chartData = signal<number[]>([]);

constructor() {
  effect(() => {
    chartLibrary.updateSeries(
      this.chartData()
    );
  });
}

These are real side effects.

Because they communicate with systems outside the signal graph.

One Table That Explains Everything

Why Angular Added Guardrails Around Effects

Angular intentionally discourages signal synchronization inside effects.

Because it creates:

  • hidden dependencies
  • unpredictable updates
  • cyclic reactivity
  • unnecessary render work

Signals are supposed to form a dependency graph.

When effects mutate signals manually, that graph becomes harder to understand.

That is why Angular pushes developers toward declarative derivations.

The Architecture Difference

Bad signal architecture feels like this:

Signal A changes
→ effect runs
→ Signal B changes
→ another effect runs
→ Signal C changes
Signal A changes
→ effect runs
→ Signal B changes
→ another effect runs
→ Signal C changes

This becomes reactive spaghetti.

Good signal architecture feels like this:

Signal A changes
→ computed values automatically recalculate
Signal A changes
→ computed values automatically recalculate
  1. Simple.
  2. Predictable.
  3. Scalable.

Final Takeaway

Go to your codebase right now. Search for effect. Count how many contain .set() or .update() on another signal. That number should be close to zero. If it is not — you now know exactly what to fix. The signal graph is supposed to do the heavy lifting. Let it.”

This article builds upon patterns shared by Roberto Hecker in his exploration of Angular Signals