Skip to content

Instantly share code, notes, and snippets.

@mpapec
Last active September 6, 2016 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpapec/6a435514e8b8f0264357c1f91b84f26f to your computer and use it in GitHub Desktop.
Save mpapec/6a435514e8b8f0264357c1f91b84f26f to your computer and use it in GitHub Desktop.
helper iodelay => sub {
my ($c, $cb) = @_;
return sub {
my @arg = @_;
return ref(shift(@arg))
? Mojo::IOLoop->delay(@_)->catch(sub{ $cb->($c, $_[1]) })
: $cb->($c, undef, @arg);
};
};
my $flow = $c->iodelay($cb);
$flow->(
sub { },
sub {
$flow->(return => 44, 55);
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment