A behavioral design pattern in which observers subscribe to notifications published by a subject whose state or activity changes.
The Observer pattern lets a subject notify registered observers when something changes. It provides an in-memory publish/subscribe mechanism for separating secondary reactions from a module’s core responsibilities. section 6.2.4
Use it when:
A domain module needs to trigger an optional reaction without taking on that reaction as a core responsibility. section 6.2.4
Keep in mind that observers can run within the subject’s transaction. For notification delivery that should not delay order creation, asynchronous messaging provides greater decoupling. section 6.2.4
Figure 6.17 Another simple domain modular collaboration pattern is the Observer pattern. For example, the Order Management domain module can notify Notification Management when it creates an Order.
Shows Order Management notifying Notification Management when it creates an order. section 6.2.4
How Microservices Patterns, Second Edition covers it
How deep it goes
Defines subjects and observers and describes transaction behavior, but gives no implementation details.
Examples
Uses order creation triggering Notification Management to send a confirmation email.
What you can do after
Apply it to notify observers of domain changes while keeping secondary reactions outside the subject’s core responsibility.
How it connects
Connects to the Open-Closed Principle, transaction-per-operation, and asynchronous messaging.
Idiomatic RustThe observer pattern is a behavioral design pattern in which a subject notifies registered observers about events without depending on their concrete implementations.
Django in ActionThe observer/observable pattern is a design pattern in which observers register interest in an observable and receive notifications when its state or activity changes.
model-view-presenterused by · Model-View-Presenter is a user-interface architectural pattern that separates model logic, view concerns, and presentation coordination into distinct responsibilities.
patternkind of · A pattern is a reusable approach to solving a recurring problem within a particular context.
design patternkind of · A design pattern is a reusable, general solution structure for a recurring software design problem.
publish-subscribe patternimplements · The publish-subscribe pattern is a messaging model in which publishers send messages to channels or topics and subscribers receive messages for which they have registered interest, without direct coupling between them.
callbackalternative to · A callback is a function or other callable supplied or registered with a component for invocation at a specified event, condition, or point in execution.
This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.