1MooseX::POE(3) User Contributed Perl Documentation MooseX::POE(3)
2
3
4
6 MooseX::POE - The Illicit Love Child of Moose and POE
7
9 version 0.215
10
12 package Counter;
13 use MooseX::POE;
14
15 has count => (
16 isa => 'Int',
17 is => 'rw',
18 lazy => 1,
19 default => sub { 0 },
20 );
21
22 sub START {
23 my ($self) = @_;
24 $self->yield('increment');
25 }
26
27 event increment => sub {
28 my ($self) = @_;
29 print "Count is now " . $self->count . "\n";
30 $self->count( $self->count + 1 );
31 $self->yield('increment') unless $self->count > 3;
32 };
33
34 no MooseX::POE;
35
36 Counter->new();
37 POE::Kernel->run();
38
39 or with MooseX::Declare:
40
41 class Counter {
42 use MooseX::POE::SweetArgs qw(event);
43
44 has count => (
45 isa => 'Int',
46 is => 'rw',
47 lazy => 1,
48 default => sub { 0 },
49 );
50
51 sub START {
52 my ($self) = @_;
53 $self->yield('increment')
54 }
55
56 event increment => sub {
57 my ($self) = @_;
58 print "Count is now " . $self->count . "\n";
59 $self->count( $self->count + 1 );
60 $self->yield('increment') unless $self->count > 3;
61 }
62 }
63
64 Counter->new();
65 POE::Kernel->run();
66
68 MooseX::POE is a Moose wrapper around a POE::Session.
69
71 event $name $subref
72 Create an event handler named $name.
73
74 get_session_id
75 Get the internal POE Session ID, this is useful to hand to other POE
76 aware functions.
77
78 yield
79 call
80 delay
81 alarm
82 alarm_add
83 delay_add
84 alarm_set
85 alarm_adjust
86 alarm_remove
87 alarm_remove_all
88 delay_set
89 delay_adjust
90 A cheap alias for the same POE::Kernel function which will gurantee
91 posting to the object's session.
92
93 STARTALL
94 STOPALL
97 Default POE-related methods are provided by
98 MooseX::POE::Meta::Trait::Object which is applied to your base class
99 (which is usually Moose::Object) when you use this module. See that
100 module for the documentation for. Below is a list of methods on that
101 class so you know what to look for:
102
104 MooseX::Declare support is still "experimental". Meaning that I don't
105 use it, I don't have any code that uses it, and thus I can't adequately
106 say that it won't cause monkeys to fly out of any orifices on your body
107 beyond what the tests and the SYNOPSIS cover.
108
109 That said there are a few caveats that have turned up during testing.
110
111 1. The "method" keyword doesn't seem to work as expected. This is an
112 integration issue that is being resolved but I want to wait for
113 MooseX::Declare to gain some more polish on their slurpy arguments.
114
115 2. MooseX::POE attempts to re-export Moose, which MooseX::Declare has
116 already exported in a custom fashion. This means that you'll get a
117 keyword clash between the features that MooseX::Declare handles for you
118 and the features that Moose handles. To work around this you'll need to
119 write:
120
121 use MooseX::POE qw(event);
122 # or
123 use MooseX::POE::SweetArgs qw(event);
124 # or
125 use MooseX::POE::Role qw(event);
126
127 to keep MooseX::POE from exporting the sugar that MooseX::Declare
128 doesn't like. This is fixed in the Git version of MooseX::Declare but
129 that version (as of this writing) is not on the CPAN.
130
133 • Chris Prather <chris@prather.org>
134
135 • Ash Berlin <ash@cpan.org>
136
137 • Chris Williams <chris@bingosnet.co.uk>
138
139 • Yuval (nothingmuch) Kogman
140
141 • Torsten Raudssus <torsten@raudssus.de> <http://www.raudssus.de/>
142
144 This software is copyright (c) 2010 by Chris Prather, Ash Berlin, Chris
145 Williams, Yuval Kogman, Torsten Raudssus.
146
147 This is free software; you can redistribute it and/or modify it under
148 the same terms as the Perl 5 programming language system itself.
149
150
151
152perl v5.34.0 2021-07-22 MooseX::POE(3)