Skip to content

Struggling with the simplest example #56

Description

@RobertEcker

Hi everybody,

<?php
require __DIR__ . '/async/vendor/autoload.php';

use React\EventLoop\Loop;
use React\Promise\Promise;
use function React\Async\await;
use function React\Async\async;


Loop::addTimer(0.5, React\Async\async(function() {
    echo 'a';
    React\async\await(React\Promise\Timer\sleep(1.0));
    echo 'c'; // not echoed?
}));

Loop::addTimer(1.0, fn() => echo 'b'); // line 16

I am already struggling with the simplest example (copied from the main page).
I am using PHP 8.1.2 on Win10 with the newest async.

  1. There is an unexpected token "echo" in line 16.
  2. When I comment line 16 with // in the beginning, the output is just 'a' (without 'c') - why not 'ac'?

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions