Ch. 4 · Angular

Angular Signals and Immutable Collection Updates

Angular Signals and Immutable Collection Updates. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readbeginnerupdated Oct 3, 2026

Signal updates depend on equality and tracked reads. Mutating an object inside a signal without replacing its value can leave consumers unaware.

Before you start

You should understand a component’s class, template and dependencies. Follow both the framework lifecycle and the ownership of each value or resource. Apply examples inside an Angular application; the surrounding application configuration and imports depend on the feature being demonstrated.

The practical goal is to reason through this situation: Update an item by mapping to a new array and replacing the modified object. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Locate shared references

An array signal contains both an array and nested item objects. Mutation can preserve both identities.

Step 2: Replace changed ownership

Use update to return a new array and a new object for the changed item. Keep unchanged items stable.

Step 3: Read through the signal

Ensure consumers call the signal where reactive tracking is intended. A copied nonreactive value does not become tracked automatically.

Worked scenario

Update an item by mapping to a new array and replacing the modified object.

const items = signal([{ id: 1, selected: false }]);
items.update(list => list.map(item => item.id === 1
  ? { ...item, selected: true } : item));
TypeScript

The changed array and item now have new identities. Pushing into items() or changing an item’s field would mutate the old value without establishing that replacement.

Common mistake

Calling set with the same mutated reference may not notify consumers under default equality.

Verify the behavior

Compare old and new array and item references. Test an unchanged ID and verify unrelated items retain identity.

Interview exercise

Update one selected record.

Answer and reasoning

Use update to return a new collection with a new changed record, preserving unchanged records’ identities.

Continue learning

Compare the scenario with the Angular interview questions and test your understanding with the Angular MCQs. For terminology and implementation details, consult the reference material.

More in Angular

read ✓Angular · mid

Angular Defer Blocks and Lazy Rendering

Load template regions on demand with @defer, choose a trigger, and use placeholders without delaying critical content.

~2 min readread →
esc