Skip to content

Commit 1827c7e

Browse files
committed
wip
1 parent 6e36e88 commit 1827c7e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/2-features/08-events.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,31 @@ final readonly class EventLoggerMiddleware implements EventBusMiddleware
159159
{ /* … */ }
160160
```
161161

162+
## Stopping event propagation
163+
164+
In rare cases you might want an event only to be handled by a single handler. You can use the `b{Tempest\EventBus\StopsPropagation}` attribute on both events and event handlers to achieve this:
165+
166+
```php
167+
use Tempest\EventBus\StopsPropagation;
168+
169+
#[StopsPropagation]
170+
final class MyEvent {}
171+
```
172+
173+
```php
174+
use Tempest\EventBus\StopsPropagation;
175+
use Tempest\EventBus\EventHandler;
176+
177+
final class MyHandler
178+
{
179+
#[StopsPropagation]
180+
public function handle(OtherEvent $event): void
181+
{
182+
// …
183+
}
184+
}
185+
```
186+
162187
## Built-in framework events
163188

164189
Tempest includes a few built-in events that are primarily used internally. While most applications won’t need them, you are free to listen to them if desired.

0 commit comments

Comments
 (0)