I'm feeling a bit confused. I am working on creating a class that performs certain actions, and at a specific point in the process, I need to trigger an event to indicate completion. However, I can't seem to find information on how to implement events in JavaScript. Can someone provide some insight on this matter?
class MyClass {
constructor() {}
test() {
// Do Stuff
// TRIGGER EVENT: onTest
}
}
-------------------------
script.js
-------------------------
let myClass = new MyClass();
// How do I register the event listener here?
// myClass on event onTest () = {dostuff;}
myClass.test();