Angular · Junior · Question 68 of 75

How do you update a signal based on its current value?

count = signal(0);
increment() { this.count.update((c) => c + 1); }

Explanation

set(value) replaces the value; update(fn) derives the new one from the old. Both notify everything that reads the signal.

Further reading

Problem with a question

Angular · Junior · question 68

Test yourself

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

Take this quiz