feat(#10): reset camera position after changing level
This commit is contained in:
parent
e2c439d1f3
commit
abf334607e
6 changed files with 47 additions and 2 deletions
32
modules/event-emitter.js
Normal file
32
modules/event-emitter.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
class EventEmitterSingleton {
|
||||
static instance;
|
||||
eventEmitter;
|
||||
|
||||
constructor() {
|
||||
this.eventEmitter = {};
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
if (!EventEmitterSingleton.instance) {
|
||||
EventEmitterSingleton.instance = new EventEmitterSingleton();
|
||||
}
|
||||
return EventEmitterSingleton.instance;
|
||||
}
|
||||
|
||||
on(eventName, callback) {
|
||||
if (!this.eventEmitter[eventName]) {
|
||||
this.eventEmitter[eventName] = [];
|
||||
}
|
||||
this.eventEmitter[eventName].push(callback);
|
||||
}
|
||||
|
||||
emit(eventName, ...args) {
|
||||
if (this.eventEmitter[eventName]) {
|
||||
this.eventEmitter[eventName].forEach((callback) => {
|
||||
callback(...args);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const eventEmitter = EventEmitterSingleton.getInstance();
|
Loading…
Add table
Add a link
Reference in a new issue