Skip to content
🔔 Event Emitter implementation.
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.coveralls.yml
.gitattributes
.gitignore
.travis.yml
LICENSE.md
README.md
composer.json
composer.lock
phpcs.xml
pre-commit

README.md

Webino Event Emitter

Event Emitter implementation.

Build Status Coverage Status Code Quality Latest Stable Version

Quick Use

Emitting an event:

use Webino\EventEmitter;

$emitter = new EventEmitter;

// registering closure event handler
$emitter->on('example', function () {
    return 'Hello';
});

// emitting custom event
$event = $emitter->emit('example');

/** @var \Webino\EventResults $results */
$results = $event->getResults();

echo $results;

// => Hello

Removing an event handler:

use Webino\EventEmitter;

$emitter = new EventEmitter;

$handler = function () {
    return 'Hello';
};

$emitter->on('example', $handler);

// remove handler for all events
$emitter->off($handler);

// remove all handlers for an event
$emitter->off(null, 'example');

// remove all handlers for all events
$emitter->off();

Emitting an event until:

use Webino\EventEmitter;

$emitter = new EventEmitter;

$emitter->on('example', function () {
    return 'Special';
});

$event = $emitter->emit('example', function ($result) {
    // when result meets required condition
    if ('Special' === $result) {
        // stop propagation
        return false;
    }
    // or continue
    return true;
});

Setup

PHP from Packagist

composer require webino\event-emitter

Development

Build Status Coverage Status Code Quality Latest Unstable Version

Static analysis:

composer analyse

Coding style check:

composer check

Coding style fix:

composer fix

Testing:

composer test

Git pre-commit setup:

ln -s ../../pre-commit .git/hooks/pre-commit

Addendum

License Total Downloads GitHub code size in bytes

Please, if you are interested in this library report any issues and don't hesitate to contribute. We will appreciate any contributions on development of this library.

GitHub issues GitHub forks

You can’t perform that action at this time.