IT lexicon › Programming › Observer pattern

Observer pattern

Programming På svenska → Updated: 2026-07-30

An object (subject) holds a list of "observers" and notifies them when it changes. Foundation of reactive programming, event systems, MVC.

Classic Gang of Four pattern (1994). Implementations: addEventListener in DOM, Rx Observables, Pub/Sub, Vue/React reactivity, Java PropertyChangeListener. Risk: memory leaks when observers forget to unsubscribe (weakref-based solutions mitigate). Modern alternatives: signals (SolidJS), atoms (Recoil/Jotai), automatic dependency tracking.

← Back to the lexicon