line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Events; |
2
|
1
|
|
|
1
|
|
67312
|
use Mojo::Base -base; |
|
1
|
|
|
|
|
191402
|
|
|
1
|
|
|
|
|
9
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
679
|
use Mojo::Events::Dispatcher; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
5
|
1
|
|
|
1
|
|
39
|
use Mojo::Events::Listeners; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
25
|
use Mojo::Server; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.0.2'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has app => sub { Mojo::Server->new->build_app('Mojo::HelloWorld') }, weak => 1; |
12
|
|
|
|
|
|
|
has namespaces => sub { [] }; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has dispatcher => sub { |
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return Mojo::Events::Dispatcher->new(app => $self->app, namespaces => $self->namespaces); |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
1; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=encoding utf8 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Mojo::Events - Dispatch and handle sync/async events in Mojolicious |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use Mojo::Events; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $events = Mojo::Events->new(app => $app, namespaces => ['Listeners::Namespace']); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$events->dispatcher->dispatch(say => 'Hello!'); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
L is a very basic implementation for events/listeners |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
L inherits all attributes from L. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
L inherits all methods from L and implements |
47
|
|
|
|
|
|
|
the following new ones. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $events = Mojo::Events->new(app => $app, namespaces => ['Listeners::Namespace']); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Events manipulator object. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 dispatcher |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $dispatcher = $events->dispatcher; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# dispatch an event |
60
|
|
|
|
|
|
|
$dispatcher->dispatch(event_name => ()); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# register a new listener |
63
|
|
|
|
|
|
|
$dispatcher->register(My::Custom::Listener->new(app => $mojolicious)); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Events dispatcher. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SEE ALSO |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L, L, L. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |