How can I create an event that is attached to a class object?
I have to create a class that has an event that should be called at a certain time. The class looks like this and should call the event newMember when a new one is added. What works is that I attach a custom event to the window and call it which is not my goal.
Not NodeJS.
class Room {
constructor() {
this.members = {}
}
addMember(data) {
if (!this.members[data.remotesid]) {
this.members[data.socket] = data.identity
//this.dispatchEvent();
} else {
console.log('Member already in room')
}
}
}