Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bring back IO::Async recipe
  • Loading branch information
kraih committed Aug 23, 2012
1 parent 9ffa441 commit 84b683a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -625,7 +625,27 @@ which can be combined to solve some of hardest problems in web development.

Internally the L<Mojo::IOLoop> event loop can use multiple reactor backends,
L<EV> for example will be automatically used if installed. Which in turn
allows other event loops like L<AnyEvent> to just work.
allows other event loops like L<IO::Async> to just work.

use Mojolicious::Lite;
use EV;
use IO::Async::Loop::EV;
use IO::Async::Timer::Absolute;

my $loop = IO::Async::Loop::EV->new;

# Wait 3 seconds before rendering a response
get '/' => sub {
my $self = shift;
$loop->add(IO::Async::Timer::Absolute->new(
time => time + 3,
on_expire => sub { $self->render(text => 'Delayed by 3 seconds!') }
));
};

app->start;

Same for L<AnyEvent>.

use Mojolicious::Lite;
use EV;
Expand Down

0 comments on commit 84b683a

Please sign in to comment.