I have class for each of my page. So for Home, i have a home class and inside the home class are several HTMLElements. However, i want to dispatch an event from my home class that isn't tied to any particular HTMLElement so that my app.js can take action.
So for example:
export class app {
private home: Home;
constructor() {
super();
this.home = new Home();
home.addEventListener(HomeEvent.TEST, this.myFunction);
//HomeEvent.TEST is just a static constant value "home-animation-event".
}
}
again, this is probably trivial but I don't think I want to necessarily tie the eventlistener to a dom element or have app extend HTMLElement. What's the best approach for this please?