https://github.com/krakphp/event-emitter
Event Emitter
https://github.com/krakphp/event-emitter
Last synced: about 1 year ago
JSON representation
Event Emitter
- Host: GitHub
- URL: https://github.com/krakphp/event-emitter
- Owner: krakphp
- Created: 2017-03-19T03:39:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-19T04:33:21.000Z (about 9 years ago)
- Last Synced: 2025-03-03T23:52:37.630Z (over 1 year ago)
- Language: PHP
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
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);
```