The GoF Observer pattern is also referred to as a publish-subscribe pattern in the GoF book. The idea is simple. EventSource (classes that emits events) will have a one-to-many relationship with event sinks (classes that listen to the event notification). Every EventSource will have a mechanism for the event sinks to subscribe to, in order to get different types of notification. A single EventSource might emit multiple events. An EventSource can send notifications to thousands of subscribers (event sinks or listeners) when there is a change in state or something significant happens in its realm. The EventSource will walk through the list of subscribers and notify them one by one. The GoF book was written at a time ...
The GoF Observer pattern
Get C++ Reactive Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.