You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2-features/08-events.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,6 +159,31 @@ final readonly class EventLoggerMiddleware implements EventBusMiddleware
159
159
{ /* … */ }
160
160
```
161
161
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
+
162
187
## Built-in framework events
163
188
164
189
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