Download bobs game/src/core/EventBus.js from Snapkitty/sov-kernel-monster: direct link, hf CLI and curl.
- Browser
- Download file 402 Bytes
-
https://huggingface.co/Snapkitty/sov-kernel-monster/resolve/main/bobs%20game/src/core/EventBus.js
- Command line
-
hf download 'hf://Snapkitty/sov-kernel-monster/bobs game/src/core/EventBus.js'
-
curl -L -o EventBus.js https://huggingface.co/Snapkitty/sov-kernel-monster/resolve/main/bobs%20game/src/core/EventBus.js
402 Bytes
| export class EventBus { | |
| constructor() { | |
| this.listeners = new Map(); | |
| } | |
| on(type, handler) { | |
| if (!this.listeners.has(type)) this.listeners.set(type, new Set()); | |
| this.listeners.get(type).add(handler); | |
| return () => this.listeners.get(type)?.delete(handler); | |
| } | |
| emit(type, payload) { | |
| for (const handler of this.listeners.get(type) || []) handler(payload); | |
| } | |
| } | |