line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Promises6::Listener; |
2
|
28
|
|
|
28
|
|
752
|
use Evo -class, -modern; |
|
28
|
|
|
|
|
29
|
|
|
28
|
|
|
|
|
131
|
|
3
|
28
|
|
|
28
|
|
5325
|
use Promises6::Util 'PROGRESS'; |
|
28
|
|
|
|
|
38
|
|
|
28
|
|
|
|
|
6049
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has [qw(deferred builder)]; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# onFulfill, onReject, onProgress |
8
|
|
|
|
|
|
|
has cbs => sub { [] }; |
9
|
|
|
|
|
|
|
|
10
|
173
|
50
|
|
173
|
1
|
236
|
sub get_msg($self, $state, $val) { |
|
173
|
50
|
|
|
|
248
|
|
|
173
|
|
|
|
|
129
|
|
|
173
|
|
|
|
|
123
|
|
|
173
|
|
|
|
|
124
|
|
|
173
|
|
|
|
|
127
|
|
11
|
173
|
|
|
|
|
224
|
my $deferred = $self->deferred; |
12
|
173
|
|
|
|
|
265
|
my $cb = $self->cbs->[$state]; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# then. 1.i, 1.ii |
15
|
173
|
100
|
|
|
|
779
|
unless (ref $cb eq 'CODE') { |
16
|
29
|
100
|
|
|
|
82
|
$state == PROGRESS |
17
|
|
|
|
|
|
|
? $deferred->notify($val) |
18
|
|
|
|
|
|
|
: $deferred->change_state($state, $val); |
19
|
29
|
|
|
|
|
184
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# then 7.ii |
23
|
144
|
|
|
|
|
102
|
my $err; |
24
|
144
|
|
|
|
|
104
|
CATCH: { |
25
|
144
|
|
|
|
|
120
|
local $@; |
26
|
144
|
|
|
|
|
186
|
$val = eval { $cb->($val) }; |
|
144
|
|
|
|
|
242
|
|
27
|
144
|
|
|
|
|
14476
|
$err = $@; |
28
|
|
|
|
|
|
|
} |
29
|
144
|
100
|
|
|
|
226
|
return $deferred->reject($err) if $err; |
30
|
|
|
|
|
|
|
|
31
|
142
|
100
|
|
|
|
397
|
$state == PROGRESS ? $deferred->notify($val) : $deferred->resolve($val); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# ABSTRACT: A listener. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |