| Ratings |   | Unique User Downloads |   | Download Rankings | 
| Not yet rated by the users |  | Total: 44  |  | All time:  10,834 This week: 40  | 
 | 
| Description |   | Author  | 
This package can register event handlers and dispatch events. 
 
It provides a class that can register event handler callback functions associated with a given event name. 
 
The package can also dispatch an event with a given name by calling all callback functions registered to handle events with that name.  |  | 
  | 
 | 
Innovation award
   Nominee: 16x |  
 
 
  | 
Details
event-router
<!-- 
 -->
Router for flexible configuring of event handling behaviors.
How to install to your project
composer require smoren/event-router
Unit testing
composer install
composer test-init
composer test
Usage
use Smoren\EventRouter\Components\EventRouter;
use Smoren\EventRouter\Interfaces\EventInterface;
use Smoren\EventRouter\Events\Event;
use Smoren\EventRouter\Structs\EventConfig;
use Smoren\EventRouter\Loggers\ArrayLogger;
$router = new EventRouter(10, new ArrayLogger());
$router
    ->on(new EventConfig('origin1'), function(EventInterface $event) {
        return null;
    })
    ->on(new EventConfig('origin1', 'recursive_single'), function(EventInterface $event) {
        return new Event('origin2', 'test');
    })
    ->on(new EventConfig('origin1', 'recursive_multiple'), function(EventInterface $event) {
        return [
            new Event('origin1', 'recursive_single'),
            new Event('origin2', 'test'),
        ];
    })
    ->on(new EventConfig('origin2'), function(EventInterface $event) {
        return null;
    });
$router->send(new Event('origin1', 'first'));
 
 
|   | 
Applications that use this package | 
  | 
No pages of applications that use this class were specified.
 If you know an application of this package, send a message to the author to add a link here.