line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Beam::Listener; |
2
|
|
|
|
|
|
|
our $VERSION = '1.006'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
5
|
|
|
|
|
|
|
#pod |
6
|
|
|
|
|
|
|
#pod package MyListener; |
7
|
|
|
|
|
|
|
#pod |
8
|
|
|
|
|
|
|
#pod extends 'Beam::Listener'; |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod # add metadata with subscription time |
12
|
|
|
|
|
|
|
#pod has sub_time => is ( 'ro', |
13
|
|
|
|
|
|
|
#pod init_arg => undef, |
14
|
|
|
|
|
|
|
#pod default => sub { time() }, |
15
|
|
|
|
|
|
|
#pod ); |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod # My::Emitter consumes the Beam::Emitter role |
18
|
|
|
|
|
|
|
#pod my $emitter = My::Emitter->new; |
19
|
|
|
|
|
|
|
#pod $emitter->on( "foo", sub { |
20
|
|
|
|
|
|
|
#pod my ( $event ) = @_; |
21
|
|
|
|
|
|
|
#pod print "Foo happened!\n"; |
22
|
|
|
|
|
|
|
#pod # stop this event from continuing |
23
|
|
|
|
|
|
|
#pod $event->stop; |
24
|
|
|
|
|
|
|
#pod }, |
25
|
|
|
|
|
|
|
#pod class => MyListener |
26
|
|
|
|
|
|
|
#pod ); |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod This is the base class used by C objects to store information |
32
|
|
|
|
|
|
|
#pod about listeners. Create a subclass to add data attributes. |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =over 4 |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod =item L |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =back |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod =cut |
43
|
|
|
|
|
|
|
|
44
|
9
|
|
|
9
|
|
8598
|
use strict; |
|
9
|
|
|
|
|
17
|
|
|
9
|
|
|
|
|
375
|
|
45
|
9
|
|
|
9
|
|
44
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
332
|
|
46
|
|
|
|
|
|
|
|
47
|
9
|
|
|
9
|
|
46
|
use Types::Standard qw(:all); |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
261
|
|
48
|
9
|
|
|
9
|
|
350270
|
use Moo; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
88
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#pod =attr code |
51
|
|
|
|
|
|
|
#pod |
52
|
|
|
|
|
|
|
#pod A coderef which will be invoked when the event is distributed. |
53
|
|
|
|
|
|
|
#pod |
54
|
|
|
|
|
|
|
#pod =cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has callback => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
isa => CodeRef, |
59
|
|
|
|
|
|
|
required => 1, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |