Ed

The publish-subscribe pattern is the foundation of reactive programming. Let's build a simple event emitter from scratch!

Your Task:

  • Create an EventEmitter class (or object)
  • Implement on(event, callback) to subscribe
  • Implement emit(event, data) to trigger callbacks
  • Implement off(event, callback) to unsubscribe
  • Store listeners in an object/Map
TypeScript Solution
Loading...

Submit your code to see test results