Modelul Observer definește o dependență unu-la-mulți în care mai multe obiecte (observatori) sunt notificați automat când un alt obiect (subiectul) își schimbă starea. Permite comunicarea decuplată, bazată pe evenimente — utilizată pe scară largă în UI-uri, sisteme de evenimente și programare reactivă.
Ce face modelul Observer
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)
