Custom Event emitter/consumers in Browser Javascript outside DOM
Custom Event emitter/consumers in Browser Javascript outside DOM Currently I have the following structure, an Object WebsocketService and multiple FrontendController s. WebsocketService FrontendController The WebsocketService listens on a websocket (duh) and updates the internal application state. This means in some cases the front end must be updated with new values. WebsocketService To keep my UI code and the application logic nicely seperated I envision a design where the FrontendController s can subscribe to events emitted the WebsocketService and very likely other Services later on. FrontendController WebsocketService I have read the documentation for Creating and triggering events on MDN. But all of that is very DOM centric. My WebsocketService obviously doesn't have an addEventListener function. WebsocketService addEventListener I would prefer to not use 3th-party libraries. A hack that comes to mind is simply have an id="events" DOM Node somewhere and having...
