A side effect is an operation performed when a changing value causes an action beyond producing that value. Logging the latest signal value to localStorage is one example. section 6.1.2
Signals provide a clean place for effects: register a callback that runs when the signals it reads change. Angular tracks those dependencies and disposes the subscription when the component is destroyed. section 6.8
Keep side effects separate from signal value updates:
- Use an effect callback for actions triggered by signal changes. section 6.1.2 section 6.8
- Keep update callbacks pure: they should return the new value without changing other properties or signals. section 6.2.2
- Avoid updating another signal inside an update callback, because it can create systemic data-flow problems. section 6.2.2
Persisting a changing value
A signal containing a user preference can trigger an effect that writes its latest value to localStorage. The signal remains responsible for representing state; the effect handles the external interaction. section 6.1.2























