Skip to content

Commit

Permalink
more detailed explanation for delay helper
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 8, 2014
1 parent 13c8577 commit 0eb0214
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -230,13 +230,16 @@ Check or get name of current route.
Disable automatic rendering and use L<Mojo::IOLoop/"delay"> to manage
callbacks and control the flow of events, which can help you avoid deep nested
closures and memory leaks that often result from continuation-passing style.
Calls L<Mojolicious::Controller/"render_exception"> if an error occured in one
of the steps, breaking the chain.
Also keeps a reference to L<Mojolicious::Controller/"tx"> in case the
underlying connection gets closed early and calls
L<Mojolicious::Controller/"render_exception"> if an error occured in one of
the steps, breaking the chain.
# Longer version
$c->render_later;
my $tx = $c->tx;
my $delay = Mojo::IOLoop->delay(sub {...}, sub {...});
$delay->catch(sub { $c->render_exception(pop) })->wait;
$delay->catch(sub { $c->render_exception(pop) and undef $tx })->wait;
=head2 dumper
Expand Down

0 comments on commit 0eb0214

Please sign in to comment.