Expand description
A lightweight, explicit, in-process pub/sub - Laravel’s Event::dispatch/
listeners, deliberately scaled down. No persistence, no queue
involvement, no derive macro, no DI-container resolution: listeners are
registered explicitly (listeners().on::<E>(...), same “build a
registry, then publish it” shape as
larust_http::route’s named-route registry), and every listener for an
event runs synchronously, in registration order, in-process - the same
default Laravel itself uses (only a ShouldQueue listener defers
there). A listener that needs to defer real work should enqueue a
larust_queue::Job instead of doing it inline.
Structs§
Traits§
- Event
- Any plain
Clone + Send + Sync + 'staticvalue can be an event - a blanket impl, no derive, no required methods.Cloneis required because each of possibly-several listeners for one dispatch gets its own owned copy to move into its independently-'staticfuture.
Functions§
- dispatch
- Runs every listener registered for
E, sequentially, awaiting each in turn before moving to the next. A silent no-op iflisteners()... publish()was never called, or if nothing is registered for this specificE- there’s no failure mode here worth anAppError; a listener that can fail should log its own error internally rather than short-circuit the others. - listeners
- Starts building the process-wide listener registry. Call
.on::<E>(...)for each listener, then.publish()once, typically right beforeApplication::serve().