await()

Similar to JavaScript, Async and Await characters are used to create a promise to wait, it will wait until a promise or callback, async finishes running.

function job() {
    return "This is my job";
}

function testSync() {
    var_dump("Hello World");
}

function testAsync() {
    new Async(function () {
        $result = Async::await(job());
        var_dump($result);
    });
}

testAsync();
testSync();

Output:

Hello World    
This is my job

Last updated