0 day streak
javascript / beginner
Snippet

Reactive State with signals

Signals are the modern way to manage reactive state in Angular. They provide a high-performance way to notify the framework when data changes.

snippet.js
javascript
1
2
3
4
5
count = signal(0);
increment() {
this.count.update(v => v + 1);
}
angular
Breakdown
1
count = signal(0);
Initializes a new signal with a starting value of 0.
2
this.count.update(...);
Uses the update method to change the value based on the current state.