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

v1.0.4 2018-05-31 18:17 UTC

This package is auto-updated.

Last update: 2024-12-25 10:47:23 UTC


README

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