Το μοτίβο Observer ορίζει μια σχέση ένα-προς-πολλά όπου πολλά αντικείμενα (observers) ειδοποιούνται αυτόματα όταν ένα άλλο αντικείμενο (το subject) αλλάζει κατάσταση. Επιτρέπει αποσυζευγμένη, event-driven επικοινωνία — ευρέως χρησιμοποιούμενη σε UIs, event systems και reactive programming.
Τι κάνει το μοτίβο 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)
