Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show how to use promises sequentially
  • Loading branch information
kraih committed Nov 26, 2017
1 parent 57f258e commit 9c08894
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/Mojo/Promise.pm
Expand Up @@ -142,6 +142,19 @@ Mojo::Promise - Promises/A+
return $promise;
}
# Perform non-blocking operations sequentially
get('http://mojolicious.org')->then(sub {
my $mojo = shift;
say $mojo->res->code;
return get('http://metacpan.org');
})->then(sub {
my $cpan = shift;
say $cpan->res->code;
})->catch(sub {
my $err = shift;
warn "Something went wrong: $err";
})->wait;
# Synchronize non-blocking operations (all)
my $mojo = get('http://mojolicious.org');
my $cpan = get('http://metacpan.org');
Expand Down

0 comments on commit 9c08894

Please sign in to comment.