PHP code example of wyrihaximus / react-parallel-future-to-promise-converter
1. Go to this page and download the library: Download wyrihaximus/react-parallel-future-to-promise-converter 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/ */
wyrihaximus / react-parallel-future-to-promise-converter example snippets
use React\EventLoop\Factory;
use React\EventLoop\LoopInterface;
use WyriHaximus\React\Parallel\FutureToPromiseConverter;
$loop = Factory::create();
$converter = new FutureToPromiseConverter($loop);
$runtime = new Runtime('vendor/autoload.php');
/** @var Future $future */
$future = $runtime->run(function () {
sleep(3);
return 3;
});
$converter->convert($future)->then(function ($value) {
// $value will be 3 here
});