Reflex::Callback::CodeRef - Callback adapter for plain code references
version 0.056
Used within Reflex:
use Reflex::Callbacks qw(cb_coderef); my $ct = Reflex::Timer->new( interval => 1 + rand(), auto_repeat => 1, on_tick => cb_coderef { print "coderef callback triggered\n"; }, ); $ct->run_all();
Low-level usage:
sub callback { my $arg = shift; print "hello, $arg->{name}\n"; } use Reflex::Callback; my $cb = Reflex::Callback::CodeRef->new( code_ref => \&code ); $cb->deliver(greet => { name => "world" });
Reflex::Callback::CodeRef maps the generic Reflex::Callback interface to plain coderef callbacks. Reflex::Callbacks' cb_coderef() function and other syntactic sweeteners hide the specifics.
Reflex::Callback::CodeRef's constructor takes a single named parameter, "code_ref", which should contain the coderef to be called by deliver().
Reflex::Callback::CodeRef's deliver() method invokes the coderef supplied during the callback's construction. deliver() takes two positional parameters: an event name (which is not currently used for coderef callbacks), and a hashref of named parameters to be passed to the callback.
deliver() returns whatever the coderef does.
Reflex Reflex::Callback documents the base class' generic interface. Reflex::Callbacks documents callback convenience functions.
"ACKNOWLEDGEMENTS" in Reflex "ASSISTANCE" in Reflex "AUTHORS" in Reflex "BUGS" in Reflex "BUGS" in Reflex "CONTRIBUTORS" in Reflex "COPYRIGHT" in Reflex "LICENSE" in Reflex "TODO" in Reflex
To install Reflex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Reflex
CPAN shell
perl -MCPAN -e shell install Reflex
For more information on module installation, please visit the detailed CPAN module installation guide.