dispatchEvent()
The method that sends an event object to a target so its listeners run, synchronously, before the call returns.
In more detail
Every listener has finished by the time dispatchEvent() returns. It returns false if the event was cancelable and a listener called preventDefault, which lets the sender ask listeners for permission before acting.
Related terms
- CustomEvent — A browser event type you create and name yourself, which carries any data you like in its detail property.
- EventTarget — The built-in browser interface for anything that can receive events, providing addEventListener, removeEventListener and dispatchEvent.
- preventDefault — A method on an event that cancels the browser's built-in action, such as submitting a form or following a link.
Taught in
- Event Phases: Capturing, Target And Bubbling Demystified — Frontend Architecture & Web Platform
- CustomEvent Dispatching And Decoupled Component Event Buses — Frontend Architecture & Web Platform