LLDbeginner
Observer Pattern
Observer supports one-to-many notification when object state changes. It is common in UI systems, event notifications, and subscription-based designs.
Reading time
8 min
observerpatternseventssubscriptions
Core Idea
A subject publishes state changes and many observers react to them. This is useful when multiple components need to stay informed without tight coupling.
Examples
- UI listeners
- Event notifications
- Stock or market feed subscribers
- Internal domain events
Cautions
- Memory leaks if observers are not removed
- Event ordering may be unclear
- Excessive fan-out can hide dependencies
Interview Tip
Observer is a strong pattern choice when one state change must trigger multiple reactions.