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 AnyEvent::CallbackStack manpage for details.
Use 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 } );
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;
Start and walk through the Callback Stack from step 0.
$cs->start( 'foo' );
Add (append) callback into the Callback Stack.
$cs->add( $code_ref );
Check out from the current step and pass value to the next callback in callback stack.
$cs->next( @result );
IMPORTANT: Remember that only if you call this method, the next callback in stack will be triggered.
Experimental.
Start the callback flow from the specified step.
$cs->step( 3, @data );
Get the very last AnyEvent::CondVar object.
Usually it's called when you are writing a module and need to return it to your caller.
my $cv = $cs->last; # or return $cs->last;
BlueT - Matthew Lien - 練喆明, <BlueT at BlueT.org>
<BlueT at BlueT.org>
Please report any bugs or feature requests to bug-anyevent-callbackstack at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-CallbackStack. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-anyevent-callbackstack at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc AnyEvent::CallbackStack
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-CallbackStack
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/AnyEvent-CallbackStack
CPAN Ratings
http://cpanratings.perl.org/d/AnyEvent-CallbackStack
Search CPAN
http://search.cpan.org/dist/AnyEvent-CallbackStack/
Launchpad
https://launchpad.net/p5-anyevent-callbackstack
GitHub
https://github.com/BlueT/AnyEvent-CallbackStack
Copyright 2012 BlueT - Matthew Lien - 練喆明.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install AnyEvent::CallbackStack, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::CallbackStack
CPAN shell
perl -MCPAN -e shell install AnyEvent::CallbackStack
For more information on module installation, please visit the detailed CPAN module installation guide.