Download the PHP package lufiipe/simplevent without Composer
On this page you can find all versions of the php package lufiipe/simplevent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package simplevent
SimplEvent
Simple PHP event listener library.
With the ability to set a priority for each listener, pause/resume, define the number of times a listener can be triggered.
Install
Usage
Usage with parameter
with multiple parameters
An event can have multiple listeners.
Notice
Listeners are triggered in the order of their declaration.
Notice
The event name must contain letters, numbers, dots, and underscores.
Priority
Since it is possible to attach multiple listeners to an event, it is also possible to assign a priority to each listener. More the priority value are higher, the sooner the listener will be called.
The above example will output:
Available priority constants
ListenerPriority::MAX: Max priorityListenerPriority::HIGH: High priorityListenerPriority::NORMAL: Normal priority (by default)ListenerPriority::LOW: Low priorityListenerPriority::MIN: MIN priority
Notice
Like closures, priorities cannot be changed once declared.
Pause/Resume
Pause
It is possible to pause the listeners
The above example will output:
Resume
And to resume just use the resume() method of your listener.
The above example will output:
Run the listener multiple times
Specify the number of times the listener can be called.
In this example, the listeners for the "EventX" event will be triggered once.
In the example below, listeners will be triggered three times.
The above example will output:
Available times constants
ListenerTimes::ALWAYS: Always listen (by default)ListenerTimes::NEVER: Never listenListenerTimes::ONCE: Listen one time
Remove all listeners from an event
Reset all events
License
The MIT License (MIT). Please see License File for more information.