Bird
0
0

Consider this Angular code snippet:

hard📝 Application Q9 of 15
Angular - Signals
Consider this Angular code snippet:
const count = signal(0);
const doubled = computed(() => count() * 2);
count.set(4);
console.log(doubled());
How does this behavior differ if count was an observable instead of a signal?
Acomputed does not work with signals
Bcomputed would update automatically with observable as well
Ccomputed would not update automatically; manual subscription needed
DNo difference; both update synchronously
Step-by-Step Solution
Solution:
  1. Step 1: Understand computed with signals

    Computed automatically recalculates when dependent signals change.
  2. Step 2: Behavior with observables

    Observables require subscriptions; computed does not auto-update from observables.
  3. Final Answer:

    computed would not update automatically; manual subscription needed -> Option C
  4. Quick Check:

    Computed auto-update difference = A [OK]
Quick Trick: Computed auto-updates only with signals, not observables [OK]
Common Mistakes:
  • Assuming computed works automatically with observables
  • Confusing reactive patterns of signals and observables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes