Observer pattern ले एक-देखि-धेरै निर्भरता परिभाषित गर्छ जहाँ धेरै वस्तुहरू (observers) स्वचालित रूपमा सूचित हुन्छन् जब अर्को वस्तु (subject) को अवस्था परिवर्तन हुन्छ। यसले अलग-अलग, event-driven संचार सक्षम गर्छ — यो UIs, 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)
