Skip to content

Commit

Permalink
show some callback examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 26, 2017
1 parent 6544a40 commit dbf81f6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/Mojo/IOLoop/Delay.pm
Expand Up @@ -426,6 +426,12 @@ L<Mojo::IOLoop::Delay> object resolving to the return value of the callback if
it is called, or to its original fulfillment value if the promise is instead
fulfilled.
$delay->catch(sub {
my @reason = @_;
warn "Something went wrong: $reason[0]";
return @reason;
});
=head2 data
my $hash = $delay->data;
Expand All @@ -449,6 +455,11 @@ Appends a fulfillment and rejection handler to the promise, and returns a new
L<Mojo::IOLoop::Delay> object resolving to the original fulfillment value or
rejection reason.
$delay->finally(sub {
my @value_or_reason = @_;
say "We are done!";
});
=head2 pass
$delay = $delay->pass;
Expand Down Expand Up @@ -500,6 +511,17 @@ Appends fulfillment and rejection handlers to the promise, and returns a new
L<Mojo::IOLoop::Delay> object resolving to the return value of the called
handler.
$delay->then(sub {
my @value = @_;
say "The result is $value[0]";
return @value;
},
sub {
my @reason = @_;
warn "Something went wrong: $reason[0]";
return @reason;
});
=head2 wait
$delay->wait;
Expand Down

0 comments on commit dbf81f6

Please sign in to comment.