PHP code example of adimihaila / promise-wait

1. Go to this page and download the library: Download adimihaila/promise-wait 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/ */

    

adimihaila / promise-wait example snippets




use React\Promise\Deferred;

function doAsyncSomething() {
    $deferred = new Deferred();
    $deferred->resolve($value);

    return $deferred->promise();
}

$value = doAsyncSomething()
    ->then(function ($response) {
        sleep(5);
        
        return $response++;
    });
    
echo \AdiMihaila\Promise\wait($value);