Skip to content

Commit 7d7d839

Browse files
committed
Document type Tap
one of the few types we have covered completely, I believe :-)
1 parent d3311df commit 7d7d839

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

lib/Type/Supply.pod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ called, indicating an erroneous termination of the supply.
5959
The C<&closing> callback is called when somebody closes the tap (which
6060
terminates that subscription, but keeps the supply as a whole in tact).
6161
62-
Method C<tap> returns an object of type C<Tap>, on which you can call the
63-
C<close> method to cancle the subscription.
62+
Method C<tap> returns an object of type L<Tap|/type/Tap>, on which you can
63+
call the C<close> method to cancle the subscription.
6464
6565
=head2 method emit
6666

lib/Type/Tap.pod

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
=begin pod
2+
3+
=TITLE class Tap
4+
5+
=SUBTITLE A subscription to a supply
6+
7+
class Tap { ... }
8+
9+
A Tap is a subscription to a L<Supply|/type/Supply>.
10+
11+
my $s = Supply.new;
12+
my $tap = $s.tap(
13+
-> $v { say "the value is $v" },
14+
done => { say "Supply is done" },
15+
closing => { say "Tap closed" },
16+
quit => -> $ex { say "Supply finished with error $ex" },
17+
);
18+
19+
# later
20+
$tap.close;
21+
# or
22+
$s.close($tap);
23+
24+
=head1 Methods
25+
26+
=head2 method emit
27+
28+
method emit(Tap:D:) returns Callable:D
29+
30+
Returns the callback that is called for emitted events.
31+
32+
=head2 method done
33+
34+
method done(Tap:D:)
35+
36+
Returns the callback that is called on successfully shutting down a channel,
37+
if any.
38+
39+
=head2 method quit
40+
41+
method quit(Tap:D:)
42+
43+
Returns the callback that is called on shutting down a channel with error, if
44+
any.
45+
46+
=head2 method closing
47+
48+
method closing(Tap:D:)
49+
50+
Returns the callback that is called on closing the tap.
51+
52+
=head2 method supply
53+
54+
method supply(Tap:D:)
55+
56+
Returns the supply to which the tap belongs.
57+
58+
=head2 method close
59+
60+
method closing(Tap:D:)
61+
62+
Closes the tap.
63+
64+
=end pod

0 commit comments

Comments
 (0)