Skip Menu |

This queue is for tickets about the Promises CPAN distribution.

Report information
The Basics
Id: 96790
Status: open
Priority: 0/
Queue: Promises

People
Owner: stevan.little [...] gmail.com
Requestors: POWERMAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Mojo::UserAgent example for Promises::Cookbook::TIMTOWTDI
#!/usr/bin/perl use Mojo::Base -strict; use Mojo::UserAgent; my $titles; my $ua = Mojo::UserAgent->new; Mojo::IOLoop->delay( sub { my $delay = shift; $ua->get('http://google.com/', $delay->begin); $ua->get('http://yahoo.com/', $delay->begin); $ua->get('http://perlmonks.org/', $delay->begin); }, sub { my ($delay, $tx1, $tx2, $tx3) = @_; $titles = { google => $tx1->res->dom->at('title')->text, yahoo => $tx2->res->dom->at('title')->text, perlmonks => $tx3->res->dom->at('title')->text, }; }, )->catch( sub { my ($delay, $err) = @_; warn "failed to download or parse title\n"; } )->wait; say Mojo::Util::dumper($titles);
Merged to master. Can be closed.