AnyEvent-CallbackStack

 view release on metacpan or  search on metacpan

lib/AE/CS.pm  view on Meta::CPAN

package AE::CS;

use AnyEvent::CallbackStack;

our $VERSION = $AnyEvent::CallbackStack::VERSION;

=encoding utf8

=head1 NAME

AE::CS - Shorter AnyEvent::CallbackStack API.

Inspired by AE.
Starting with version 0.05, AnyEvent::CallbackStack officially supports a second, much
simpler in name, API that is designed to reduce the typing.

There is No Magic like what AE has on reducing calling and memory overhead.

See the L<AnyEvent::CallbackStack> manpage for details.

=head1 SYNOPSIS

Use L<AE::CS> with the following style.

	use feature 'say';
	use AnyEvent::CallbackStack;
	
	my $cs = AE::CS;
	my $cv = AE::cv;
	
	$cs->add( sub { $cv->send( $_[0]->recv ) } );
	$cs->start('hello world');
	say $cv->recv;

# or

	my $cs = AE::CS;
	http_get http://BlueT.org => sub { $cs->start($_[0]) };
	$cs->add( sub { say $_[0]->recv } );

# or

	my $cs = AE::CS;
	my %foo = (bar => vbar, yohoo => vyohoo);
	
	$cs->start( %foo );
	$cs->add( sub {
		my %foo = $_[0]->recv;
		$cs->next( $foo{'bar'}, $foo{'yohoo'} );
	});
	
	$cv = $cs->last;
	$cv->cb( sub {
		my @a = $_[0]->recv;
		$cv->send( $a[0].$a[1] )
	});
	
	say $cv->recv;


=head1 METHODS

=head2 start

Start and walk through the Callback Stack from step 0.

	$cs->start( 'foo' );



( run in 1.775 second using v1.01-cache-2.11-cpan-39bf76dae61 )