Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 54 lines (42 sloc) 0.993 kb
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
1 #!/usr/bin/env perl
2
b811c714 »
2009-09-20 Give the fourth sortie a new name. It's 53% done now!
3 use warnings;
4 use strict;
9e56da91 »
2009-09-23 Add the examples to the distribution, and ensure they run in their ne…
5 use lib qw(../lib);
b811c714 »
2009-09-20 Give the fourth sortie a new name. It's 53% done now!
6
7 # Exercise Reflex::POE::Postback, for passing postbacks into POE space.
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
8
9 {
10 package App;
11
12 use Moose;
1f5ed273 »
2010-06-27 Rename Reflex::Role::Object to Reflex::Role::Reactive; Reflex::Object…
13 extends 'Reflex::Base';
b811c714 »
2009-09-20 Give the fourth sortie a new name. It's 53% done now!
14 use Reflex::POE::Postback;
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
15 use PoCoPostback;
16
17 has component => (
18 isa => 'Object|Undef',
19 is => 'rw',
20 );
21
22 sub BUILD {
23 my $self = shift;
f32ece5c »
2011-01-24 Improve the comments in the POE component examples. Rob Bloodgood poi…
24
25 # PoCoPostbck is used as an object.
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
26 $self->component( PoCoPostback->new() );
27
f32ece5c »
2011-01-24 Improve the comments in the POE component examples. Rob Bloodgood poi…
28 # Send the component a Reflex::POE::Postback, which looks and
29 # feels like a POE::Session postback but invokes Reflex callbacks.
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
30 $self->component->request(
b811c714 »
2009-09-20 Give the fourth sortie a new name. It's 53% done now!
31 Reflex::POE::Postback->new(
32 $self, "on_component_result", { cookie => 123 }
33 ),
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
34 );
35 }
36
37 sub on_component_result {
38 my ($self, $args) = @_;
39 print(
40 "Got component response:\n",
b811c714 »
2009-09-20 Give the fourth sortie a new name. It's 53% done now!
41 " postback context: $args->{context}{cookie}\n",
42 " call-back result: $args->{response}[0]\n",
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
43 );
44
45 # Ok, we're done.
46 $self->component(undef);
47 }
48 }
49
b811c714 »
2009-09-20 Give the fourth sortie a new name. It's 53% done now!
50 # Main.
51
bf57dfb9 »
2009-09-02 Support POE::Components that wish to be given postbacks.
52 my $app = App->new();
53 $app->run_all();
54 exit;
Something went wrong with that request. Please try again.