Skip to content

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

License

Notifications You must be signed in to change notification settings

flextype-components/event

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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