Performance: Service-based state management
MEDIUM IMPACT
This affects how efficiently the app updates UI and handles user interactions by centralizing state in services.
Use a singleton Angular service with RxJS BehaviorSubject to hold and emit state changes to all components.
Each component maintains its own local state and uses @Input/@Output to pass data up and down the tree.
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Local state in each component with @Input/@Output | Many duplicated DOM updates across components | Multiple reflows triggered per update | High paint cost due to redundant updates | [X] Bad |
| Centralized service state with RxJS and async pipe | Single DOM update per state change | Single reflow per update | Low paint cost with targeted updates | [OK] Good |