Design Patterns · Junior · Question 7 of 75
How does Pub/Sub differ from the classic Observer?
- ✓Correct answer: Publishers and subscribers don't know about each other - an event broker connects them
- 2In Pub/Sub there can be only one subscriber, in Observer many
- 3Pub/Sub works only synchronously, Observer only asynchronously
Explanation
In Observer, subscribers register directly with the subject. In Pub/Sub there's an intermediary (an event bus, a message broker), and participants know only channel names. This decouples parts of the system more strongly but makes the event flow harder to trace.