Question · JavaScript and TypeScript course · Module 5: Advanced JavaScript

Pub/Sub vs Observer

What is the key difference between the Observer pattern and Publish/Subscribe (Pub/Sub)?

Answer options

  • Observer only works synchronously, while Pub/Sub works asynchronously
  • In Pub/Sub, the sender and receiver communicate through channels/topics without knowing each other directly
  • Observer handles multiple events, while Pub/Sub handles only one
  • Pub/Sub requires a database, while Observer does not

You can check the correct answer by solving this task in the CodeWorlds game.