Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simon28082/event
https://github.com/simon28082/event
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/simon28082/event
- Owner: simon28082
- Created: 2017-06-01T23:42:33.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-28T12:34:19.000Z (about 5 years ago)
- Last Synced: 2024-08-14T05:12:48.809Z (3 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Example
### Set the scheduler
```$xslt
Example::setDispatcher(new \CrCms\Event\Dispatcher);
```### Register event
```$xslt
Example::registerEvent('event1',$listener);
```### Push event listener
```$xslt
Example::pushEvent('event1',$listener);
```### Listening method
```$xslt
//first
$listener => ExampleListener1::class@listen//second
$listener => ExampleListener2::class//third
$listener => function($object) {
...
}class ExampleListener1
{
public function listen($object)
{
...
}
}class ExampleListener2
{
public function handle($object)
{
...
}
}function($object) {
...
}```
### Event trigger
```$xslt
class Example {use CrCms\Event\HasEvents;
# Set events
public static function events() : array
{
return ['event1','event2'];
}
public function example()
{
# Trigger event
Example::fireEvent('event1',$listener);
}
}```