thruster/event-emitter

Thruster EventEmitter Component

1.1.0 2016-01-12 15:31 UTC

This package is auto-updated.

Last update: 2024-11-14 03:27:13 UTC


README

[Latest Version] (https://github.com/ThrusterIO/event-emitter/releases) [Software License] (LICENSE) [Build Status] (https://travis-ci.org/ThrusterIO/event-emitter) [Code Coverage] (https://scrutinizer-ci.com/g/ThrusterIO/event-emitter) [Quality Score] (https://scrutinizer-ci.com/g/ThrusterIO/event-emitter) [Total Downloads] (https://packagist.org/packages/thruster/event-emitter)

[Email] (mailto:team@thruster.io)

The Thruster EventEmitter Component.

Install

Via Composer

$ composer require thruster/event-emitter

Usage

Creating an Emitter

$emitter = new EventEmitter();

Adding Listeners

$emitter->on('foo.bar', function (Foo $bar) {
    // ... Something happend
});

Emitting Events

$emitter->emit('foo.bar', [$fooBar]);

Using Advance Event Emitter

$emitter = new AdvanceEventEmitter();

$emitter->on('foo.bar', function (EventInterface $event) {
  // ... Do something good

  $event->stopPropagation(); // you can stop further execution
});

$emitter->on('foo.bar', function (EventInterface $event) {
  // ... Never gets called
});

$emitter->emit('foo.bar', new Event($fooBar));

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

License

Please see License File for more information.