Objects that protect themselvesintermediate
A class with public setters on everything cannot stop anyone putting it in an impossible state; moving the mutation behind a named method is how the rule becomes unbreakable.
A service holding shared state in signals, with an optimistic update that rolls back exactly when the request fails. This is the stage that separates people who have read about signals from people who have shipped them.
See alsoA store without a libraryThe same store in React, built from context and a reducer rather than signals.
The checkbox flips instantly; when the request fails it flips back and an error appears.
Published in full, before you start — every point is one of these and there is nothing else.
A class with public setters on everything cannot stop anyone putting it in an impossible state; moving the mutation behind a named method is how the rule becomes unbreakable.
Anything that talks to a network can be slow or fail; a screen with no loading state and no error state is a screen that looks broken the first time the wifi drops.
Network calls fail. Code that assumes they succeed turns a slow connection into a blank screen with no explanation.
A signal is a value that tells the template when it changed, so Angular updates only what actually depends on it — and computed() derives from other signals rather than storing a second copy that can drift.
sort() and reverse() change the array you gave them, which is how a filter quietly reorders the caller's data — copy first, and the bug never exists.