export class MessageBus {
	constructor() {
		this.bus = new EventTarget()
	}

	subscribe(eventName, fn) {
		this.bus.addEventListener(eventName, fn)
	}

	unsubscribe(eventName, fn) {
		this.bus.removeEventListener(eventName, fn)
	}

	dispatch(eventName, data) {
		this.bus.dispatchEvent(new CustomEvent(eventName, { detail: data }))
	}
}
