Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
This package has been abandoned.
Generated on May 31, 2024 via composer

hoa/event 2.17.08.30

The Hoa\Event library.
Package summary
Share
0
issues
1
license
1
BSD-3-Clause
Package created
11 Nov 2015
Version published
30 Aug 2017
Maintainers
1
Total deps
1
Direct deps
0
License
BSD-3-Clause

Issues

0
This package has no issues

Licenses

BSD 3-Clause "New" or "Revised" License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
place-warranty
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
hoa/event@2.17.08.30
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of hoa/event 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does hoa/event do?

Hoa\Event is a comprehensive PHP library dedicated to providing a robust implementation of the observer design-pattern. This makes it possible to utilise events and listeners in PHP. The library enables both asynchronous and anonymous events, as well as synchronous and identified listeners. These areas cater to a broad span of data diffusion needs, ranging from isolated to close-knit components.

How do you use hoa/event?

As for how you use Hoa\Event, it's remarkably straightforward and flexible due to its implementation of callable. First, install it with Composer using the command composer require hoa/event '~2.0'.

To observe anomalies like exceptions or streams about to close, you can utilise code such as;

Hoa\Event\Event::getEvent('hoa://Event/Exception')->attach(
    function (Hoa\Event\Bucket $bucket) {
        var_dump(
            $bucket->getSource(),
            $bucket->getData()
        );
    }
);

This block of code sets up a watching eye on any exception thrown. You can streamline the process further by attaching a stream directly to an event;

Hoa\Event\Event::getEvent('hoa://Event/Exception')->attach(
    new Hoa\File\Write('Foo.log')
);

Now, every exception will be logged onto the Foo.log file.

For listeners, they ought to be synchronous and identified. To exemplify, if you have a WebSocket server and you wanted to listen to the message listener ID, the following code does the trick;

$server = new Hoa\Websocket\Server(…);
$server->on('message', function (Hoa\Event\Bucket $bucket) {
    var_dump(
        $bucket->getSource(),
        $bucket->getData()
    );
});

The closure is executed every time a message is received by the WebSocket server.

Where are the hoa/event docs?

Hoa\Event's documentation can be found at Hoa\Event documentation. The documents discuss in detail how to utilise this library and delve into how it works. Information on how to generate the docs locally is also provided if you prefer that. Furthermore, to help your understanding of Hoa libraries, they also provide help through their IRC channel or forum at users.hoa-project.net. If interested in contributing, steps are outlined in the contributor guide.