-
Notifications
You must be signed in to change notification settings - Fork 589
Open
Description
Documentation at https://metacpan.org/pod/Mojo::Promise#timer states that it should be possible to chain a timer to an existing promise.
Hence I would expect following code to produce output where the two timestamps are ten seconds apart.
use Mojo::Promise;
my $p1 = Mojo::Promise->new();
my $p2 = $p1
->then(sub { say time })
->timer(10)
->then(sub{ say time });
$p1->resolve;
$p2->wait;However this exampe terminates immediately without waiting 10 seconds in-between the two outputs.
In comparison, the following code works as expected
use Mojo::Promise;
my $p1 = Mojo::Promise->new();
my $p2 = $p1
->then(sub { say time; Mojo::Promise->timer(10) })
->then(sub{ say time });
$p1->resolve;
$p2->wait;Metadata
Metadata
Assignees
Labels
No labels