Skip to content

The Nuxed Event Dispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them asynchronously.

License

nuxed/event-dispatcher

Repository files navigation

Coding standards status Static analysis status Unit tests status Total Downloads Latest Stable Version License

Nuxed Event Dispatcher

The Event Dispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them asynchronously.

Installation

This package can be installed with Composer.

$ composer require nuxed/event-dispatcher

Example

use namespace Nuxed\EventDispatcher;
use namespace Nuxed\EventDispatcher\ListenerProvider;

<<__EntryPoint>>
async function main(): Awaitable<void> {
  $provider = new ListenerProvider\AttachableListenerProvider();

  $provider->listen<SomeEvent>(new SomeEventListener());
  $provider->listen<SomeOtherEvent>(new SomeOtherEventListener());

  $dispatcher = new EventDispatcher\EventDispatcher($provider);

  // dispatch multiple event listeners concurrently
  concurrent {
    // returns the event that was passed, now modified by listeners.
    $someEvent = await $dispatcher->dispatch<SomeEvent>(new SomeEvent());
    $someOtherEvent = await $dispatcher->dispatch<SomeOtherEvent>(new SomeOtherEvent());
  }
}

Security

For information on reporting security vulnerabilities in Nuxed, see SECURITY.md.


License

Nuxed is open-sourced software licensed under the MIT-licensed.

About

The Nuxed Event Dispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them asynchronously.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages