Event Component

version
MIT License

Event Component provides a versatile tool to manage events in your app.

Installation

composer require flextype-components/event

Usage

use Flextype\Component\Event\Event;

Add new listeners

Event::addListener('event_name', function() { echo 'Test Event 1'; }, 1);
Event::addListener('event_name', function() { echo 'Test Event 2'; }, 2);

Remove all listeners for current event.

Event::removeAllListeners('event_name');

Check is listeners exists for current event.

if (Event::hasListeners('event_name')) {
    // do something...
}

Dispatch all listeners of the given event.

Event::dispatch('event_name');

Get listeners array

$listeners = Event::getListeners();

License

See LICENSE


Download

Download on the Github