Observer pattern ఒక one-to-many dependency ను నిర్వచిస్తుంది, ఇక్కడ బహుళ objects (observers) మరొక object (subject) యొక్క స్థితి మారినప్పుడు స్వయంచాలకంగా నోటిఫై చేయబడతాయి. ఇది decoupled, event-driven communication ను సక్షమం చేస్తుంది — UI లలో, event systems లలో, మరియు reactive programming లలో విస్తృతంగా ఉపయోగించబడుతుంది.
Observer pattern ఏమి చేస్తుంది
OBSERVER → a SUBJECT maintains a list of OBSERVERS and NOTIFIES them on state changes:
→ observers SUBSCRIBE to the subject
→ when the subject changes → it notifies ALL subscribed observers automatically
→ observers react to the notification (update themselves)
→ one-to-many: one subject, many observers; DECOUPLED (subject doesn't know observer details)
