Event Bus Implementation — Publisher-Subscriber System (Part 1: Core)

Build the foundational layer of a publish-subscribe event bus system in JavaScript. Implement a class with three core methods: subscribe(event, callback) — registers a listener for a named event; publish(event, data) — triggers all listeners registered under that event name passing the data payload; unsubscribe(event, callback) — removes a specific listener. Handle multiple listeners per event, events with no listeners, and prevent duplicate subscriptions. This is the single-channel, synchronous version.

Examples
Input: []
Output:
Hints

Event Bus Implementation — Publisher-Subscriber System (Part 1: Core)

Build the foundational layer of a publish-subscribe event bus system in JavaScript. Implement a class with three core methods: subscribe(event, callback) — registers a listener for a named event; publish(event, data) — triggers all listeners registered under that event name passing the data payload; unsubscribe(event, callback) — removes a specific listener. Handle multiple listeners per event, events with no listeners, and prevent duplicate subscriptions. This is the single-channel, synchronous version.