line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Events::Dispatcher; |
2
|
1
|
|
|
1
|
|
8
|
use Mojo::Base 'Mojo::EventEmitter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
1965
|
use Mojo::Events::Listeners; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
44
|
use Mojo::Server; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has app => sub { Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1; |
8
|
|
|
|
|
|
|
has listeners => sub { |
9
|
|
|
|
|
|
|
my $self = shift; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
return Mojo::Events::Listeners->new(app => $self->app, namespaces => $self->namespaces); |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
has namespaces => sub { [] }; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 new |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Initialize dispatcher and startup listeners |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
0
|
|
|
0
|
1
|
|
my $self = shift->SUPER::new(@_); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
for my $listener (@{ $self->listeners->registered }) { |
|
0
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->on($listener->event => sub { |
26
|
0
|
|
|
0
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return $listener->handle(@_); |
29
|
0
|
|
|
|
|
|
}); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 register |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Proxy for listeners register |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub register { |
42
|
0
|
|
|
0
|
1
|
|
return shift->listeners->register(@_); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 dispatch |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Dispatch event |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub dispatch { |
52
|
0
|
|
|
0
|
1
|
|
return shift->emit(@_); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |