Documentation

EventDispatcher
in package

The event dispatcher acts as the central hub where event listeners are hosted and where events are sent. The event dispatcher can be used in two notable ways:

  • Writing global listeners with the global event() function
  • Writing scoped listeners by instantiating it within the class you need to provide extensions too

Our first way is more convenient when handling global plugins that modify the behavior of an application generically.

The second allows to target certain components of our application explicitly while reducing the risk of collissions.

Table of Contents

$listeners  : mixed
dispatch()  : type
Dispatches an event to all listeners that are expecting the event.
on()  : Listener
Creates a listener and attaches it. This will allow the listener to receive events that happen whenever an event with the same event name is fired and dispatched.

Properties

Methods

dispatch()

Dispatches an event to all listeners that are expecting the event.

public dispatch(Event $event) : type
Parameters
$event : Event
Return values
type

on()

Creates a listener and attaches it. This will allow the listener to receive events that happen whenever an event with the same event name is fired and dispatched.

public on(string $for) : Listener
Parameters
$for : string
Return values
Listener

Search results