Events Internals
Learn how events work and how to edit their internal behavior.
The events system is made up of several components that work together to detect and dispatch events.
Event system components
Specifically, these components are:
EventDispatcher: Coordinates middleware checks and subscriber execution for each dispatch.EventBus: Stores subscribers and emits events.EventSubscriber: Receives events and executes logic.
Execution Sequence
The following diagrams show the event flow in focused stages. You can check the guide of each component to see exactly how it works, or how to replace it.
Diagram usage
- You can zoom and drag on the diagram.
- A dashed step means it's executed through a non awaited (but caught) Promise, so the next one is inmediately executed if there's an I/O operation in the step.
- You can hover over steps with
(?)to see extra details. - If a step goes to a target, and that target doesn't continue the flow, then it's an immediate return, like a getter call.
Event emit
When an object emits an event through an EventBus, the bus resolves subscribers and delegates execution to the dispatcher:
Middleware gate
Before subscribers are executed, the EventDispatcher checks the event middleware list:
Subscriber dispatch
If middleware allows the dispatch, each EventSubscriber is executed and thrown errors are forwarded to the error handler:
Next, see the documentation of each component, where you'll find what it does and how to replace it.
Last updated on
