AnyEvent-CallbackStack
view release on metacpan or search on metacpan
lib/AnyEvent/CallbackStack.pm view on Meta::CPAN
package AnyEvent::CallbackStack;
our $VERSION = '0.12';
use utf8;
use feature 'say';
use common::sense;
use Data::Dumper::Simple;
use AnyEvent;
use constant DEBUG => $ENV{ANYEVENT_CALLBACKSTACK_DEBUG};
=encoding utf8
=head1 NAME
AnyEvent::CallbackStack - Turning endless nested Event-Based Callbacks into plain Sequential Style. And save your indents.
Convert nested callback into easy-to-read-write-and-maintain serial/procedural coding style by using Callback Stack.
=head1 SYNOPSIS
Use L<AnyEvent::CallbackStack> with the following style.
use feature 'say';
use AnyEvent::CallbackStack;
my $cs = AnyEvent::CallbackStack->new();
$cs->start( %foo );
$cs->add( sub {
do_something;
$cs->next( $bar, $yohoo );
});
$cv = $cs->last;
return $cv;
# or
http_get http://BlueT.org => sub { $cs->start($_[0]) };
$cs->add( sub { say $_[0]->recv; $cs->next } );
$cs->last->cb(sub {
# do something after that
# and maybe let me know someone's using my module :3
});
# or
$cs->add( sub { say 'I got the ball'; $cs->next( $_[0]->recv ); } )
print 'Your name please?: ';
chomp(my $in = <STDIN>);
$cs->start($in);
$cs->add( sub { say "Lucky you, $_[0]->recv" } );
# or
my $cs = AE::CS;
=head1 METHODS
=head2 new
No paramater needed.
my $cs = new AnyEvent::CallbackStack;
=cut
sub new {
my $class = shift;
my @cbq = ();
( run in 1.400 second using v1.01-cache-2.11-cpan-39bf76dae61 )