AlgoViz

Observer pattern

medium 50 min

Decouple a state-holding subject from its dependents: they register, and the subject notifies everyone on its list when something changes.

Chapter mnemonic

Observer notification lifecycle

Sign up. News breaks. Papers arrive. Cancel delivery.

Someone cancels the paper. What relationship must the publisher update?

Remove the subscription so future changes no longer notify that observer.