Chapter 26: The Observer Pattern
We use the observer pattern when we want to be able to inform/notify all stakeholders (an object or a group of objects) when the state of an object changes. An important feature of the observer pattern is that the number of subscribers/observers, as well as who the subscribers are, may vary and can be changed at runtime.
In this chapter, we will learn about this design pattern while comparing it to a similar one we have seen in the past, known as the MVC pattern, and use it to implement a data formatter.
Specifically, we will cover the following topics:
- Understanding the observer pattern
- Real-world examples
- Use cases
- Implementation