Listener
in package
Class \Hoa\Event\Listener.
A contrario of events, listeners are synchronous, identified at use and useful for close interactions between one or some components.
Tags
Table of Contents
Properties
- $_callables : array<string|int, mixed>
- All listener IDs and associated listeners.
- $_source : Listenable
- Source of listener (for Bucket).
Methods
- __construct() : mixed
- Build a listener.
- addIds() : void
- Add acceptable ID (or reset).
- attach() : Listener
- Attach a callable to a listenable component.
- detach() : Listener
- Detach a callable from a listenable component.
- detachAll() : Listener
- Detach all callables from a listenable component.
- fire() : array<string|int, mixed>
- Send/fire a bucket to a listener.
- listenerExists() : bool
- Check if a listener exists.
Properties
$_callables
All listener IDs and associated listeners.
protected
array<string|int, mixed>
$_callables
= []
$_source
Source of listener (for Bucket).
protected
Listenable
$_source
= null
Methods
__construct()
Build a listener.
public
__construct(Listenable $source, array<string|int, mixed> $ids) : mixed
Parameters
- $source : Listenable
-
Source (for Bucket).
- $ids : array<string|int, mixed>
-
Accepted ID.
addIds()
Add acceptable ID (or reset).
public
addIds(array<string|int, mixed> $ids) : void
Parameters
- $ids : array<string|int, mixed>
-
Accepted ID.
attach()
Attach a callable to a listenable component.
public
attach(string $listenerId, mixed $callable) : Listener
Parameters
- $listenerId : string
-
Listener ID.
- $callable : mixed
-
Callable.
Tags
Return values
Listenerdetach()
Detach a callable from a listenable component.
public
detach(string $listenerId, mixed $callable) : Listener
Parameters
- $listenerId : string
-
Listener ID.
- $callable : mixed
-
Callable.
Return values
ListenerdetachAll()
Detach all callables from a listenable component.
public
detachAll(string $listenerId) : Listener
Parameters
- $listenerId : string
-
Listener ID.
Return values
Listenerfire()
Send/fire a bucket to a listener.
public
fire(string $listenerId, Bucket $data) : array<string|int, mixed>
Parameters
- $listenerId : string
-
Listener ID.
- $data : Bucket
-
Data.
Tags
Return values
array<string|int, mixed>listenerExists()
Check if a listener exists.
public
listenerExists(string $listenerId) : bool
Parameters
- $listenerId : string
-
Listener ID.