taskinbirtan / emit-listen
A simple emit/listener package
dev-master
2023-04-29 21:11 UTC
Requires
- php: >=7.4
This package is not auto-updated.
Last update: 2024-10-28 02:20:45 UTC
README
A simple emit/listener package for PHP.
Installation
Use composer to install the package:
composer require taskinbirtan/emit-listen use TaskinBirtan\EmitListen\Emitter; $emitter = new Emitter(); $emitter->on('myEvent', function ($arg1, $arg2) { // Do something with the arguments }); $emitter->emit('myEvent', 'arg1Value', 'arg2Value'); use TaskinBirtan\EmitListen\Emitter; use TaskinBirtan\EmitListen\Listener; $emitter = new Emitter(); $listener = new Listener($emitter); $listener->subscribe('myEvent', function ($arg1, $arg2) { // Do something with the arguments }); $emitter->emit('myEvent', 'arg1Value', 'arg2Value');