Skip to content

Commit

Permalink
better example for Promise.in
Browse files Browse the repository at this point in the history
  • Loading branch information
gfldex committed Jan 27, 2017
1 parent 94a5e89 commit 5145151
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions doc/Type/Promise.pod6
Expand Up @@ -73,10 +73,13 @@ this method:
Creates a new Promise that will be kept in C<$seconds> seconds, or later.
my $p = Promise.in(2).then({ say "2 seconds later" });
# do other stuff here
await $p; # wait here until the 2 seconds are over
my $proc = Proc::Async.new('perl6', '-e', 'sleep 10; warn "end"');
my $result = await Promise.anyof(
my $promise = $proc.start,
Promise.in(5).then: { note 'timeout'; $proc.kill }
).then: {$promise.result};
# OUTPUT«timeout␤»
=head2 method at
Expand Down

0 comments on commit 5145151

Please sign in to comment.