What is the Observer Pattern?

Updated Apr 28, 2026

Short answer

A behavioral pattern that lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they're observing.

Deep explanation

It establishes a one-to-many relationship between a subject and its observers. When the subject changes state, all registered observers are notified and updated automatically. This is the foundation of reactive programming and event-driven architectures.

Real-world example

A newsletter subscription system or event listeners in UI frameworks (e.g., onClick).

Common mistakes

  • Failing to unsubscribe observers, leading to memory leaks (the Lapsed Listener problem).

Follow-up questions

  • What is the Lapsed Listener Problem?

More Design Patterns interview questions

View all →