Observer pattern एक एक-ते-अनेक अवलंबित्व परिभाषित करते जिथे अनेक ऑब्जेक्ट्स (observers) स्वयंचलितपणे सूचित होतात जेव्हा दुसरा ऑब्जेक्ट (subject) स्थिती बदलतो. हे विसंबद्ध, इव्हेंट-चालित संप्रेषण सक्षम करते — व्यापकपणे UIs, इव्हेंट सिस्टम्स आणि प्रतिक्रियाशील प्रोग्रामिंगमध्ये वापरले जाते.
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)
