Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (48 sloc) 1.281 kB
#!/usr/bin/env perl
# vim: ts=2 sw=2 noexpandtab
use warnings;
use strict;
use lib qw(../lib);
# Exercise Reflex::POE::Postback, for passing postbacks into POE space.
{
package App;
use Moose;
extends 'Reflex::Base';
use Reflex::POE::Postback;
use PoCoPostback;
has component => (
isa => 'Object|Undef',
is => 'rw',
);
sub BUILD {
my $self = shift;
# PoCoPostbck is used as an object.
$self->component( PoCoPostback->new() );
# Send the component a Reflex::POE::Postback, which looks and
# feels like a POE::Session postback but invokes Reflex callbacks.
#
# The request() call here could be replaced with
# $poe_kernel->post(...) assuming you import $poe_kernel and
# understand how to address the component. PoCoPostback provides
# the request() method to gloss over these details.
$self->component->request(
Reflex::POE::Postback->new(
$self, "on_component_result", { cookie => 123 }
),
);
}
sub on_component_result {
my ($self, $event) = @_;
print(
"Got component response:\n",
" postback context: ", $event->context()->{cookie}, "\n",
" call-back result: ", $event->response()->[0], "\n",
);
# Ok, we're done.
$self->component(undef);
}
}
# Main.
my $app = App->new();
$app->run_all();
exit;
Jump to Line
Something went wrong with that request. Please try again.