Observer Pattern
The observer pattern defines a one-to-many dependency: when the subject's state changes, all registered observers are notified automatically, achieving loosely coupled event notification.
Purpose
Implement publish-subscribe style event notification, decoupling event sources from handlers.
Mechanism
The subject maintains an observer list and calls each observer's update method on state change. Observers can register/unregister dynamically. RxJS/EventEmitter are implementations. Push model (data passed) vs pull model (observer fetches).
Use cases
- Event-driven design
- MVVM data binding
- Reactive programming