eleven-x/event

Event system

v0.1.0 2016-12-29 01:32 UTC

This package is not auto-updated.

Last update: 2025-04-12 23:24:48 UTC


README

Simple php event system

Install

composer require eleven-x/event

API

addListener($eventName, \Closure $listener, $priority = 0, $once = false)

Adds the listener function to the end of the listeners array for the event named $eventName

  • $eventName event name
  • $listener listener function
  • $priority The higher the value, the higher the priority
  • $once whether it is a one-time

once($eventName, \Closure $listener)

Adds a one time listener function for the event named $eventName. The next time $eventName is triggered, this listener is removed and then invoked.

  • $eventName event name
  • $listener listener function

removeListener($eventName)

Removes the specified listener from the listener array for the event named $eventName.

  • $eventName event name

hasListeners($eventName)

Whether there is a listener

  • $eventName event name

dispatch($eventName, Event $event = null)

Calls each of the listeners registered for the event named $eventName

  • $eventName event name
  • $event Event object

License

MIT