Skip to content

Commit

Permalink
added real example for delay helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 8, 2014
1 parent 36b9849 commit d57b910
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -241,6 +241,18 @@ the steps, breaking the chain.
my $delay = Mojo::IOLoop->delay(sub {...}, sub {...});
$delay->catch(sub { $c->render_exception(pop) and undef $tx })->wait;
# Non-blocking request
$c->delay(
sub {
my $delay = shift;
$c->ua->get('http://mojolicio.us' => $delay->begin);
},
sub {
my ($delay, $tx) = @_;
$c->render(json => {title => $tx->res->dom->at('title')->text});
}
);
=head2 dumper
%= dumper {some => 'data'}
Expand Down

0 comments on commit d57b910

Please sign in to comment.