Member-only story
LLD: Observer Pattern (Behavioral)
Definition
The Observer Pattern is a behavioral design pattern where an object (aka the “subject” or “observable” or “publisher”) maintains a list of dependents (called “observers”) and automatically notifies them whenever there is a change in its state. The pattern also allows addition and removal of observers at runtime.
Real-life Examples
Real-life examples of the Observer pattern include:
- Weather Applications: Where multiple devices receive updates from a weather station.
- Social Media Feeds: When we follow someone on Instagram, Facebook, or Twitter, we become observer of their profile. When they post new content, we are automatically notified.
- Subscription Services: YouTube subscriptions, where viewers are notified of new videos, or Content magazine/newspaper/newsletter subscriptions, where publishers send new issues to subscribers.
- Stock Market Trackers: When the price of a stock (or state) changes, the stock’s market system (the observable) sends out notifications to all interested investors (the observers).






![Design an Online Game Leaderboad [System Design HLD]](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*5TfDdjkSA3CtU9R3E5ZqnQ.png)
![System Design Interview Series:3/30[Back-of-Envelope Estimation]](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*xgLXa5l3deDFviuJtxrtqA.png)
