Angular · Senior · Question 8 of 75

What is wrong with this effect?

total = signal(0);
constructor() {
  effect(() => this.total.set(this.price() * this.qty()));
}

Explanation

total = computed(() => this.price() * this.qty()) is synchronous, lazy and always consistent. Use linkedSignal if it must also be writable; reserve effects for side effects outside the signal graph (DOM, storage, logging).

Further reading

Problem with a question

Angular · Senior · question 8

Test yourself

Take the Angular · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz