Skip to content

Dispatcher

Simple event dispatcher.

Note

This package is work in progress!

Requirements

  • PHP 8.2
composer require symbiont/dispatcher

Usage

<?php

use Symbiont\Dispatcher\{EventDispatcher, Dispatcher};

// global
EventDispatcher::register('event', function($argument) { /* callback */ });
EventDispatcher::dispatch('event', ['some-argument']);
EventDispatcher::once('once-only', function($argument) { /* callback */ });
EventDispatcher::dispatch('once-only');

// object
$dispatcher = new Dispatcher;
$dispatcher
    ->register('event', function($argument) { /* callback */ })
    ->dispatch('event', ['some-argument'])
    ->once('once-only', function() { /* callback called once */ })
    ->dispatch('once-only');

Documentation

This documentation only documents the technical usage of this package with little to no text.


Testing

composer test

License

Released under MIT License