Skip to content

Commit

Permalink
fix ol items code blocks indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Aug 20, 2023
1 parent de68ebd commit 97815b0
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions events/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,30 @@ Event listeners can halt the progation of a global event to subsequent listeners

1. Returning false

```php
Event::listen('auth.login', function ($event) {
// Handle the event

return false;
});
```
```php
Event::listen('auth.login', function ($event) {
// Handle the event
return false;
});
```

2. Returning any non-null value when the event is fired with the `halt` parameter set to true:

```php
Event::listen('whos.the.captain', fn ($ship) => 'Kirk');
Event::listen('whos.the.captain', fn ($ship) => 'I am', 10);
Event::listen('whos.the.captain', fn ($ship) => null, 20);

// Returns array of results ([null, 'I am', 'Kirk'])
Event::fire('whos.the.captain', payload: ['USS Enterprise']);

// Returns first non-null result ('I am')
Event::fire('whos.the.captain', payload: ['USS Enterprise'], halt: true);
```
```php
Event::listen('whos.the.captain', fn ($ship) => 'Kirk');
Event::listen('whos.the.captain', fn ($ship) => 'I am', 10);
Event::listen('whos.the.captain', fn ($ship) => null, 20);
// Returns array of results ([null, 'I am', 'Kirk'])
Event::fire('whos.the.captain', payload: ['USS Enterprise']);
// Returns first non-null result ('I am')
Event::fire('whos.the.captain', payload: ['USS Enterprise'], halt: true);
```

>**NOTE:** [Local events](#event-emitter-trait) currently only support the second method, where the call to dispatch the event must set the `halt` parameter to true in order to allow for event halting by listeners.


### Wildcard listeners

When registering an event listener, you may use asterisks to specify wildcard listeners. Wildcard listeners will receive the event name fired first, followed by the parameters passed through to the event as an array.
Expand Down

0 comments on commit 97815b0

Please sign in to comment.