Observer Pattern
behavioralNotify multiple objects about state changes
Type: patternPrinciples
Subject maintains list of observersObservers subscribe/unsubscribeAutomatic notification on changes
When to use
Reactive UIs, event systems, pub/sub
When not to use
Simple dependencies, single observer
Pros and Cons
Ventajas
- + Low coupling
- + Broadcast changes
- + Add observers dynamically
Desventajas
- - Undefined notification order
- - Memory leaks if not unsubscribed
- - Update cascades