Last active
August 29, 2015 14:03
-
-
Save jberger/5341caa27012599e00f1 to your computer and use it in GitHub Desktop.
Mojolicious apps with delay helper (from version 5.11)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
use Mojo::IOLoop; | |
get '/error' => sub { | |
my $c = shift; | |
$c->delay( | |
sub { die 'Argh' }, | |
sub { $c->render( text => 'Lived!') }, | |
); | |
}; | |
get '/pause' => sub { | |
my $c = shift; | |
$c->delay( | |
sub { Mojo::IOLoop->timer(4 => shift->begin) }, | |
sub { $c->render(text => 'Hi') }, | |
); | |
}; | |
app->start; | |
__DATA__ | |
@@ pause.html.ep | |
This isn't what you mean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment