NAME
Reflex::Callback::CodeRef - Callback adapter for plain code references
VERSION
version 0.085
SYNOPSIS
Used within Reflex:
use Reflex::Callbacks qw(cb_coderef);
my $ct = Reflex::Interval->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" });
DESCRIPTION
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.
new
Reflex::Callback::CodeRef's constructor takes a single named parameter, "code_ref", which should contain the coderef to be called by deliver().
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.
SEE ALSO
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