Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a computed signal in Angular?
A computed signal is a special kind of signal that automatically calculates its value based on other signals. It updates whenever its dependencies change.
Click to reveal answer
beginner
How do computed signals help in managing derived state?
They keep derived values in sync automatically without manual updates, reducing bugs and making code easier to read.
Click to reveal answer
beginner
Which Angular function creates a computed signal?
The function is called computed(). You pass a function that returns the derived value.
Click to reveal answer
intermediate
What happens when a signal used inside a computed signal changes?
The computed signal automatically recalculates its value and updates any parts of the app that use it.
Click to reveal answer
advanced
Can computed signals cause infinite loops? How to avoid them?
Yes, if a computed signal indirectly depends on itself. To avoid this, ensure dependencies form a clear, acyclic graph.
Click to reveal answer
What does the Angular computed() function do?
ACreates a signal that derives its value from other signals
BCreates a signal that stores user input
CCreates a signal that never changes
DCreates a signal that triggers HTTP requests
✗ Incorrect
The computed() function creates a signal whose value depends on other signals and updates automatically.
If a signal used inside a computed signal changes, what happens?
AThe signal resets to default
BThe computed signal recalculates its value
CThe app crashes
DNothing changes automatically
✗ Incorrect
Computed signals listen to their dependencies and recalculate when those signals change.
Which of these is a benefit of using computed signals?
AManual updates of derived values
BSlower app performance
CAutomatic syncing of derived values
DMore complex code
✗ Incorrect
Computed signals automatically keep derived values in sync, making code simpler and less error-prone.
What should you avoid to prevent infinite loops with computed signals?
AHaving a computed signal depend on itself directly or indirectly
BUsing signals only once
CUsing signals in templates
DUsing signals with HTTP calls
✗ Incorrect
A computed signal must not depend on itself, or it will cause infinite recalculations.
Which Angular concept is closely related to computed signals?
ADirectives
BForms
CRouting
DSignals and reactivity
✗ Incorrect
Computed signals are part of Angular's reactive signals system.
Explain how computed signals work in Angular and why they are useful.
Think about how a calculator updates its display when you change inputs.
You got /4 concepts.
Describe a scenario where using a computed signal prevents bugs compared to manual updates.
Imagine forgetting to update a total price after changing quantity.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a computed signal in Angular's signal system?
easy
A. To replace all signals with a single global state
B. To store static data that never changes
C. To automatically update a value based on other signals when they change
D. To manually trigger UI updates
Solution
Step 1: Understand what computed signals do
Computed signals derive their value from other signals and update automatically when those signals change.
Step 2: Compare options with this behavior
Only To automatically update a value based on other signals when they change describes automatic updates based on dependencies, which matches computed signals.
Final Answer:
To automatically update a value based on other signals when they change -> Option C
Hint: Computed signals auto-update when dependencies change [OK]
Common Mistakes:
Thinking computed signals store static data
Confusing manual updates with automatic updates
Assuming computed signals replace all signals
2. Which of the following is the correct syntax to create a computed signal in Angular?
easy
A. const total = computed(() => price() + tax());
B. const total = signal(() => price + tax);
C. const total = computed(price + tax);
D. const total = signal(price() + tax());
Solution
Step 1: Recall computed signal syntax
Computed signals use computed(() => ...) with a function returning the derived value.
Step 2: Check each option
const total = computed(() => price() + tax()); correctly uses computed(() => price() + tax()). const total = signal(() => price + tax); wrongly uses signal and no function. const total = computed(price + tax); misses the function wrapper. const total = signal(price() + tax()); uses signal instead of computed.
Final Answer:
const total = computed(() => price() + tax()); -> Option A
Quick Check:
Computed syntax = computed(() => value) [OK]
Hint: Use computed(() => ...) with a function for derived values [OK]
Common Mistakes:
Using signal() instead of computed() for derived values
Passing expressions directly without a function
Not calling dependent signals as functions
3. Given the code below, what will be logged after count.set(5) is called?
A. Computed signals cannot use arithmetic operations
B. Signals must be called as functions inside computed
C. Signals cannot be used inside computed
D. Missing initial value for tax signal
Solution
Step 1: Check how signals are accessed
Signals are functions and must be called with () to get their current value.
Step 2: Analyze the computed expression
The expression uses price and tax directly without calling them, so it uses the signal objects, not their values.
Final Answer:
Signals must be called as functions inside computed -> Option B
Quick Check:
Access signals with () inside computed [OK]
Hint: Always call signals as functions inside computed [OK]
Common Mistakes:
Using signal variables directly without ()
Thinking computed disallows arithmetic
Ignoring signal initial values
5. You want to create a computed signal that returns the full name by combining two signals: firstName and lastName. Which code correctly updates the full name when either signal changes and avoids unnecessary recomputations?
hard
A. const fullName = computed(() => firstName() + lastName());
B. const fullName = signal(`${firstName()} ${lastName()}`);