mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Loading of levels is working now
This commit is contained in:
25
js/events/EventBus.js
Normal file
25
js/events/EventBus.js
Normal file
@@ -0,0 +1,25 @@
|
||||
export class EventBus
|
||||
{
|
||||
static listeners = []
|
||||
|
||||
static addEventListener(eventName, callback)
|
||||
{
|
||||
EventBus.listeners.push({eventName, callback});
|
||||
|
||||
window.addEventListener(eventName, callback, false);
|
||||
}
|
||||
|
||||
static dispatchEvent(event)
|
||||
{
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
|
||||
static clear()
|
||||
{
|
||||
for (const listener of EventBus.listeners) {
|
||||
window.removeEventListener(listener.eventName, listener.callback, false);
|
||||
}
|
||||
|
||||
EventBus.listeners = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user