liveBook · Manning

Observer pattern

The observer pattern is a behavioral design pattern in which a subject notifies registered observers when its state or activity changes.

How 4 Manning books explain it

Software Design for Python Programmers

A behavioral design pattern in which dependent objects are notified when an observed object's state changes.

How it is used
Supports publisher–subscriber architectures where one component produces data for independently implemented consumers.
How deep it goes
Defines Subject, Observer, notification, attachment, detachment, and state retrieval through a worked Python application and generic model.
Examples
Uses news streaming, baseball hit events, logs, statistical tables, bar charts, and a fan-club bulletin.
What you can do after
Build it from scratch by defining Subject and Observer roles, wiring subscriptions, notifying observers, and letting each observer process state independently.

Read how Software Design for Python Programmers explains observer pattern →

Object-Oriented Software Design in C++

A design pattern that defines a one-to-many dependency so observers are notified when a subject changes state.

How it is used
Uses one publisher to distribute changing content to multiple independently implemented subscribers.
How deep it goes
Explains the one-to-many structure and C++ notification flow through Subject, Observer, attach(), detach(), and notify().
Examples
Demonstrates baseball hit events through log, graph, table, and player-specific fan-club reports.
What you can do after
Apply it by defining a Subject, an Observer update contract, subscription operations, and publisher notifications.

Read how Object-Oriented Software Design in C++ explains observer pattern →

Idiomatic Rust

The observer pattern is a behavioral design pattern in which a subject notifies registered observers about events without depending on their concrete implementations.

How it is used
Enables subjects to notify observers about events in event-processing and event-handling systems.
How deep it goes
Defines observer and observable traits, then implements registration, removal, and notification with shared and weak pointers.
Examples
Demonstrates a string-state subject notifying two named observers that print the observed state.
What you can do after
Build a Rust observer implementation with traits, registration methods, and weak references.

Read how Idiomatic Rust explains observer pattern →

Django in Action

The observer/observable pattern is a design pattern in which observers register interest in an observable and receive notifications when its state or activity changes.

How it is used
Automates side effects after ORM events, especially creating a UserProfile when a User is created.
How deep it goes
Explains registration, senders, pre/post timing, creation checks, and duplicate protection, but does not develop a general signal architecture.
Examples
Demonstrates a post_save User handler that creates a missing UserProfile across application, Admin, and fixture workflows.
What you can do after
Build it from scratch by registering a Django signal handler and safely creating a related model as a save side effect.

Read how Django in Action explains observer pattern →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.