Observer-mönstret definierar en en-till-många-beroende där flera objekt (observatörer) notifieras automatiskt när ett annat objekt (subjektet) ändrar tillstånd. Det möjliggör frikopplad, händelsestyrd kommunikation — allmänt använt i UIs, händelsesystem och reaktiv programmering.
Vad Observer-mönstret gör
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)
