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)
