Purpose: Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
- Use Cases:
- Event Listeners: In GUIs,
components like buttons or text fields notify observers (e.g., listeners)
of user actions or changes.
- Publish-Subscribe Systems: News feeds
or notification systems use observers to broadcast updates to multiple
subscribers.
No comments:
Post a Comment