In each of my page classes, such as Home, I have specific HTMLElements. However, I want to trigger an event from the Home class that doesn't depend on any particular HTMLElement, allowing my app.js to respond accordingly.
For instance:
export class app {
private home: Home;
constructor() {
super();
this.home = new Home();
home.addEventListener(HomeEvent.TEST, this.myFunction);
//HomeEvent.TEST is simply a static constant value "home-animation-event".
}
}
While it may seem like a minor issue, I prefer not to directly link the event listener to a DOM element or make app extend HTMLElement. What would be the best approach for achieving this?