Reflex::POE::Postback - Communicate with POE components expecting postbacks.
version 0.060
Not a complete example. Please see eg-11-poco-postback.pl in the eg directory for a complete working program.
my $postback = Reflex::POE::Postback->new( $self, "on_component_result", { cookie => 123 } );
Reflex::POE::Postback creates an object that's substitutes for POE::Session postbacks. When invoked, however, they sent events back to the object and method (and with optional continuation data) provided during construction.
Reflex::POE::Postback was designed to interact with POE modules that want to respond via caller-provided postbacks. Authors are encouraged to encapsulate POE interaction within Reflex objects. Most users should therefore not need use Reflex::POE::Postback (or other Reflex::POE helpers) directly.
new() constructs a new Reflex::POE::Postback object, which will be a blessed coderef following POE's postback convention.
It takes three positional parameters: the required object and method to invoke when the postback is called, and an optional context that will be passed verbatim to the callback.
The "context" callback parameter contains whatever was supplied to the Reflex::POE::Postback when it was created. In the case of the SYNOPSIS, that would be:
sub on_component_result { my ($self, $arg) = @_; # Displays: 123 print $arg->{context}{cookie}, "\n"; }
"response" contains an array reference that holds whatever was passed to the postback. If we assume this postback call:
$postback->(qw(eight six seven five three oh nine));
Then the callback might look something like this:
sub on_component_result { my ($self, $arg) = @_; # Displays: nine print "$arg->{response}[-1]\n"; }
Reflex::POE::Postback must produce objects as blessed coderefs. This is something I don't know how to do yet with Moose, so Moose isn't used. Therefore, Reflex::POE::Postback doesn't do a lot of things one might expect after working with other Reflex objects.
If Moose can be used later, it may fundamentally change the entire interface. The goal is to do this only once, however.
It might be nice to map positional response parameters to named parameters. Reflex::POE::Wheel does this, but it remains to be seen whether that's considered cumbersome.
Moose::Manual::Concepts
Reflex Reflex::POE::Event Reflex::POE::Session Reflex::POE::Wheel::Run Reflex::POE::Wheel
"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.