Skip to content
Newer
Older
100644 61 lines (48 sloc) 1.25 KB
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
1 #!/usr/bin/env perl
5b0127b @rcaputo Remove emit() from roles.
authored May 29, 2011
2 # vim: ts=2 sw=2 noexpandtab
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
3
b811c71 @rcaputo Give the fourth sortie a new name. It's 53% done now!
authored Sep 20, 2009
4 use warnings;
5 use strict;
9e56da9 @rcaputo Add the examples to the distribution, and ensure they run in their ne…
authored Sep 23, 2009
6 use lib qw(../lib);
b811c71 @rcaputo Give the fourth sortie a new name. It's 53% done now!
authored Sep 20, 2009
7
8 # Exercise Reflex::POE::Postback, for passing postbacks into POE space.
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
9
10 {
11 package App;
12
13 use Moose;
1f5ed27 @rcaputo Rename Reflex::Role::Object to Reflex::Role::Reactive; Reflex::Object…
authored Jun 27, 2010
14 extends 'Reflex::Base';
b811c71 @rcaputo Give the fourth sortie a new name. It's 53% done now!
authored Sep 20, 2009
15 use Reflex::POE::Postback;
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
16 use PoCoPostback;
17
18 has component => (
19 isa => 'Object|Undef',
20 is => 'rw',
21 );
22
23 sub BUILD {
24 my $self = shift;
f32ece5 @rcaputo Improve the comments in the POE component examples. Rob Bloodgood poi…
authored Jan 24, 2011
25
26 # PoCoPostbck is used as an object.
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
27 $self->component( PoCoPostback->new() );
28
f32ece5 @rcaputo Improve the comments in the POE component examples. Rob Bloodgood poi…
authored Jan 24, 2011
29 # Send the component a Reflex::POE::Postback, which looks and
30 # feels like a POE::Session postback but invokes Reflex callbacks.
3bd9acb @rcaputo Explain that request() is a convenience method to gloss over the deta…
authored Jan 24, 2011
31 #
32 # The request() call here could be replaced with
33 # $poe_kernel->post(...) assuming you import $poe_kernel and
34 # understand how to address the component. PoCoPostback provides
35 # the request() method to gloss over these details.
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
36 $self->component->request(
b811c71 @rcaputo Give the fourth sortie a new name. It's 53% done now!
authored Sep 20, 2009
37 Reflex::POE::Postback->new(
38 $self, "on_component_result", { cookie => 123 }
39 ),
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
40 );
41 }
42
43 sub on_component_result {
5c57d49 @rcaputo !!! Experiment with Reflex events being objects.
authored Oct 25, 2011
44 my ($self, $event) = @_;
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
45 print(
46 "Got component response:\n",
5c57d49 @rcaputo !!! Experiment with Reflex events being objects.
authored Oct 25, 2011
47 " postback context: ", $event->context()->{cookie}, "\n",
48 " call-back result: ", $event->response()->[0], "\n",
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
49 );
50
51 # Ok, we're done.
52 $self->component(undef);
53 }
54 }
55
b811c71 @rcaputo Give the fourth sortie a new name. It's 53% done now!
authored Sep 20, 2009
56 # Main.
57
bf57dfb @rcaputo Support POE::Components that wish to be given postbacks.
authored Sep 2, 2009
58 my $app = App->new();
59 $app->run_all();
60 exit;
Something went wrong with that request. Please try again.