Documentation

Event
in package

Class \Hoa\Event\Event.

Events are asynchronous at registration, anonymous at use (until we receive a bucket) and useful to largely spread data through components without any known connection between them.

Tags
copyright

Copyright © 2007-2017 Hoa community

license

New BSD License

Table of Contents

Constants

KEY_EVENT  = 0
Event ID key.
KEY_SOURCE  = 1
Source object key.

Properties

$_callable  : array<string|int, mixed>
Callables, i.e. observer objects.
$_register  : array<string|int, mixed>
Static register of all observable objects, i.e. \Hoa\Event\Source object, i.e. object that can send event.

Methods

attach()  : Event
Attach an object to an event.
detach()  : Event
Detach an object to an event.
eventExists()  : bool
Check whether an event exists.
getEvent()  : Event
Manage multiton of events, with the principle of asynchronous attachments.
isListened()  : bool
Check if at least one callable is attached to an event.
notify()  : void
Notify, i.e. send data to observers.
register()  : void
Declare a new object in the observable collection.
unregister()  : void
Undeclare an object in the observable collection.
__construct()  : mixed
Privatize the constructor.

Constants

KEY_EVENT

Event ID key.

public mixed KEY_EVENT = 0
Tags
const

int

KEY_SOURCE

Source object key.

public mixed KEY_SOURCE = 1
Tags
const

int

Properties

$_callable

Callables, i.e. observer objects.

protected array<string|int, mixed> $_callable = []

$_register

Static register of all observable objects, i.e. \Hoa\Event\Source object, i.e. object that can send event.

private static array<string|int, mixed> $_register = []

Methods

attach()

Attach an object to an event.

public attach(mixed $callable) : Event

It can be a callable or an accepted callable form (please, see the \Hoa\Consistency\Xcallable class).

Parameters
$callable : mixed

Callable.

Return values
Event

detach()

Detach an object to an event.

public detach(mixed $callable) : Event

Please see $this->attach() method.

Parameters
$callable : mixed

Callable.

Return values
Event

eventExists()

Check whether an event exists.

public static eventExists(string $eventId) : bool
Parameters
$eventId : string

Event ID.

Return values
bool

getEvent()

Manage multiton of events, with the principle of asynchronous attachments.

public static getEvent(string $eventId) : Event
Parameters
$eventId : string

Event ID.

Return values
Event

isListened()

Check if at least one callable is attached to an event.

public isListened() : bool
Return values
bool

notify()

Notify, i.e. send data to observers.

public static notify(string $eventId, Source $source, Bucket $data) : void
Parameters
$eventId : string

Event ID.

$source : Source

Source.

$data : Bucket

Data.

Tags
throws
Exception

register()

Declare a new object in the observable collection.

public static register(string $eventId, Source|string $source) : void

Note: Hoa's libraries use hoa://Event/AnID for their observable objects;

Parameters
$eventId : string

Event ID.

$source : Source|string

Observable object or class.

Tags
throws
Exception

unregister()

Undeclare an object in the observable collection.

public static unregister(string $eventId[, bool $hard = false ]) : void
Parameters
$eventId : string

Event ID.

$hard : bool = false

If false, just delete the source, else, delete source and attached callables.

__construct()

Privatize the constructor.

private __construct() : mixed

        
On this page

Search results