class EventEmitter implements EventEmitterInterface

Our Event Emitter, equivalent to Node.js' Event Emitter.

Traits

Our Event Emitter Trait.

Properties

protected array $listeners from EventEmitterTrait
protected array $onceListeners from EventEmitterTrait

Methods

$this
on(string $event, callable $listener)

Attach a listener to an event.

$this
once(string $event, callable $listener)

Attach a listener to an event, for exactly once.

$this
removeListener(string $event, callable $listener)

Remove specified listener from an event.

$this
removeAllListeners(string|null $event = null)

Remove all listeners from an event (or all listeners).

array
listeners(string|null $event = null)

Get listeners for a specific events, or all listeners.

void
emit(string $event, mixed ...$arguments)

Emits an event, catching all exceptions and emitting an error event for these exceptions.

Details

in EventEmitterTrait at line 34
$this on(string $event, callable $listener)

Attach a listener to an event.

Parameters

string $event
callable $listener

Return Value

$this

in EventEmitterTrait at line 50
$this once(string $event, callable $listener)

Attach a listener to an event, for exactly once.

Parameters

string $event
callable $listener

Return Value

$this

in EventEmitterTrait at line 66
$this removeListener(string $event, callable $listener)

Remove specified listener from an event.

Parameters

string $event
callable $listener

Return Value

$this

in EventEmitterTrait at line 95
$this removeAllListeners(string|null $event = null)

Remove all listeners from an event (or all listeners).

Parameters

string|null $event

Return Value

$this

in EventEmitterTrait at line 116
array listeners(string|null $event = null)

Get listeners for a specific events, or all listeners.

Parameters

string|null $event

Return Value

array

in EventEmitterTrait at line 143
void emit(string $event, mixed ...$arguments)

Emits an event, catching all exceptions and emitting an error event for these exceptions.

Parameters

string $event
mixed ...$arguments

Return Value

void