An open API service indexing awesome lists of open source software.

https://github.com/krakphp/event-emitter

Event Emitter
https://github.com/krakphp/event-emitter

Last synced: about 1 year ago
JSON representation

Event Emitter

Awesome Lists containing this project

README

          

# Event Emitter

Simple event emitter package with a lot of flexibility. Inspired by the Evenement library, EventEmitter provides a simple interface for adding and emitting events.

## Installation

Install with composer at `krak/event-emitter`

## Usage

```php
on('event', function($arg) {
echo "Hello $arg\n";
});
$emitter->emit('event', "World");
```

This is the event emitter interface:

```php
on('event', new AcmeListener());
```

### Custom Invocation

The default emitter supports custom invocations via the [Krak\\Invoke](https://github.com/krakphp/invoke) library. You can easily pass in a custom invoker which provides flexibility with how your listeners will be invoked.

```php
on('event', 'service_id');
$emitter->emit('event', 1);
```