ASYNC FEATURE
Sync Events
Dispatch an event and all sync listeners run before the response is sent.
Feature Guide
A quick orientation block that answers the essential questions: what this feature does, how it works, why it matters, and the key concepts behind it.
What this does
Events decouple side effects from handlers. Dispatch an event and listeners react — notifications, cache invalidation, analytics.
How it works
EventDispatcher::create() builds the event, dispatch() triggers all registered listeners, and propagated events can also be mirrored into Semitexa Ledger for cross-node delivery. #[AsEventListener] marks listener classes. Default execution is synchronous in the same coroutine.
Why it matters
Events let handlers focus on the main task. Side effects belong in listeners, keeping handler code clean and each concern independently testable.
Key concepts
- #[AsEventListener]
- Registers a class as a listener for a specific event type.
- #[Propagated]
- Marks an event for ledger persistence and cross-node propagation when the ledger runtime is enabled.
- EventDispatcher
- Core service for creating and dispatching domain events.
Inline Dispatch
Fire an event in the current request
No event fired yet. Submit the form to dispatch DemoItemCreated.
Verified against Semitexa Ultimate 2026.09.19.1020
Sync Events
Synchronous listeners execute inline before the response is sent. When you dispatch an event in sync mode, every registered listener completes its work before the HTTP response is returned to the client.
How it works
The event dispatcher calls each sync listener in registration order within the current request lifecycle. The response is not flushed until all sync listeners have returned.
Why this matters
Sync execution guarantees that listener side effects are complete before the client sees the response. This is the right choice for validation side effects, required audit writes, or any work the response depends on. When the ledger runtime is enabled, propagated events are also written to the node ledger after sync listener execution.
How it works
EventDispatcher::create() builds the event, dispatch() triggers all registered listeners, and propagated events can also be mirrored into Semitexa Ledger for cross-node delivery. #[AsEventListener] marks listener classes. Default execution is synchronous in the same coroutine.
Why it matters
Events let handlers focus on the main task. Side effects belong in listeners, keeping handler code clean and each concern independently testable.
Key concepts
- #[AsEventListener]
- Registers a class as a listener for a specific event type.
- #[Propagated]
- Marks an event for ledger persistence and cross-node propagation when the ledger runtime is enabled.
- EventDispatcher
- Core service for creating and dispatching domain events.