Last active
January 4, 2018 21:06
-
-
Save simonecesano/0ed2163c2ba4e635d458611963027762 to your computer and use it in GitHub Desktop.
Render and then do slow things inside Mojolicious::Lite app
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
get '/timer' => sub { | |
my $c = shift; | |
# $c->render_later; not needed | |
my $delay = Mojo::IOLoop->delay(sub { | |
$c->app->log->info('Delay finished!'); | |
$c->render(text => 'timer!'); | |
}); | |
$delay->begin->(); | |
for my $i (0 .. 5) { | |
app->log->info("outside timer " . $i); | |
Mojo::IOLoop->timer(0 => sub { | |
app->log->info('in timer ' . $i); | |
}); | |
} | |
Mojo::IOLoop->start unless Mojo::IOLoop->is_running; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment