Events
Three lifecycle events are dispatched by the real dispatcher (including when execution is allowed under a fake):
| Event | When |
|---|---|
ActionDispatching | Before handle() |
ActionDispatched | After a successful handle() |
ActionFailed | When handle() throws (exception is rethrown) |
use BradieTilley\Actions\Events\ActionDispatched;
use BradieTilley\Actions\Events\ActionDispatching;
use BradieTilley\Actions\Events\ActionFailed;
use Illuminate\Support\Facades\Event;
Event::listen(ActionDispatching::class, function (ActionDispatching $event) {
// $event->action
});
Event::listen(ActionDispatched::class, function (ActionDispatched $event) {
// $event->action
// $event->value
// $event->duration // BradieTilley\Actions\Duration
});
Event::listen(ActionFailed::class, function (ActionFailed $event) {
// $event->action
// $event->error
});
Duration
ActionDispatched::$duration is a BradieTilley\Actions\Duration value object
with asNanoseconds(), asMicroseconds(), asMilliseconds(), asSeconds(),
and __toString().
Continue to Extensibility.