PHP code example of justblackbird / amphp-priority-emitter

1. Go to this page and download the library: Download justblackbird/amphp-priority-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/ */

    

justblackbird / amphp-priority-emitter example snippets


use Amp\Loop;
use JustBlackBird\AmpPriorityEmitter\Emitter;

// The following example will output:
// - important message
// - message one
// - message two

Loop::run(static function() {
    $emitter = new Emitter();

    $emitter->emit('message one', 0);
    $emitter->emit('message two', 0);
    $emitter->emit('important message', 5);
    $emitter->complete();

    $iterator = $emitter->iterate();
    while(yield $iterator->advance()) {
        echo "- " . $iterator->getCurrent() . "\n";        
    }
});