shancept/event

v1.0.2 2022-11-28 11:55 UTC

This package is auto-updated.

Last update: 2024-03-28 14:56:12 UTC


README

Events allow you to insert custom code into existing code at specific points in execution. You can attach custom code to an event so that when the event fires, the code is automatically executed.

install:

composer require shancept/event

Usage:

first case

  1. create event class implements EventInterface. Example.
  2. create event handler class. Example.
  3. call trigger event at the right place Event::trigger(new Event()).
  4. subscribe to the event before executing it Event::listen(SomeClass::class, static function ($event) {}).

second case

  1. use trait in your class.
  2. record all events via EventTrait::recordEvent.
  3. call in the right place: EventBus::dispatch().
  4. pass EventTrait::releaseEvents result to the "dispatch" function parameter.