PHP code example of thruster / event-emitter

1. Go to this page and download the library: Download thruster/event-emitter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thruster / event-emitter example snippets


$emitter = new EventEmitter();

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

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

$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));