Real-world examples
In reality, an auction resembles the observer pattern. Every auction bidder has a numbered paddle that is raised whenever they want to place a bid. Whenever the paddle is raised by a bidder, the auctioneer acts as the subject by updating the price of the bid and broadcasting the new price to all bidders (subscribers).
In software, we can cite at least two examples:
- Kivy, the Python framework for developing user interfaces, has a module called Properties, which implements the observer pattern. Using this technique, you can specify what should happen when a property's value changes.
- The RabbitMQ library can be used to add asynchronous messaging support to an application. Several messaging protocols are supported, such as HTTP and AMQP. RabbitMQ can be used in a Python application to implement a publish-subscribe pattern, which is nothing more than the observer design pattern (j.mp/rabbitmqobs).
In the next section, we will discuss when this...