Design an Event Emitter
Design a generic event emitter (pub-sub). Include listener registration and removal, event emission to multiple subscribers, wildcard events, and once-only listeners.
Suggested time: 45 minutes
Loading the workspace...
About this problem
An event emitter seems like a simple pub/sub: register a callback, fire it. But underneath, the system must handle thread-safe listener registration and removal during emission, support once-only listeners via decorators, provide cancellation propagation, and optionally support async delivery. Let's break this down.
What your design needs to cover
Register Event Listeners
Emit Events
Remove Listeners
Once-Only Listeners
Key challenges the editorial covers
Learn from other designs
Related problems
Design a Restaurant Order System (medium)
Design a Social Media Platform (medium)
Design a Voting Booth System (medium)
Design a Warehouse Management System (medium)
Design a Warehouse Inventory Tracker (medium)
Design a Workout Planner (medium)