EventTarget
The built-in browser interface for anything that can receive events, providing addEventListener, removeEventListener and dispatchEvent.
In more detail
Listeners on an EventTarget are called in the order they were added. Elements, window and many other objects implement it, and you can create or extend it yourself to build an event bus without any library.
Related terms
- CustomEvent — A browser event type you create and name yourself, which carries any data you like in its detail property.
- event bus — A shared object that parts of an application use to publish events and subscribe to them, so senders and receivers never reference each other directly.
- dispatchEvent() — The method that sends an event object to a target so its listeners run, synchronously, before the call returns.
- EventEmitter — The Node.js class for objects that emit named events and call registered listener functions, similar to the browser's EventTarget.
Taught in
- CustomEvent Dispatching And Decoupled Component Event Buses — Frontend Architecture & Web Platform