System Design
15. Software Design PatternsAnimated
Observer Pattern
Notify dependants when something changes.
The idea
Subjects keep a list of observers and tell them about changes.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- client
- gateway / proxy
- service
- cache
- data store
- queue / stream
A service publishes an event: "OrderPlaced".
- step:
- 1/4
- at:
- Producer
1/8
The green dot is a request moving through the system.
Step by step
- 1Observers subscribe
- 2The subject changes
- 3It notifies observers
- 4They update
Where it is used
Events and UI updates.
Watch out for
Memory leaks from forgotten subscriptions.