adimihaila/promise-wait

This package is abandoned and no longer maintained. No replacement package was suggested.

Provides a wait functionality for ReactPHP/Promise library.

1.0.2 2018-05-29 07:20 UTC

This package is auto-updated.

Last update: 2024-06-18 22:28:13 UTC


README

ReactPHP promise/wait Build Status

This lightweight library provides a wait functionality for ReactPHP/promise library.

Installation

composer require adimihaila/promise-wait

Usage

<?php

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