Skip to content

Commit 112a72d

Browse files
authored
Merge pull request #2655 from Kaiepi/supply2
Document the :&tap parameter of Supply.tap
2 parents 4d472ac + 3b5b051 commit 112a72d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

doc/Type/Supply.pod6

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Further examples can be found in the L<concurrency page|/language/concurrency#Su
5353
method tap(Supply:D: &emit = -> $ { },
5454
:&done,
5555
:&quit,
56+
:&tap
5657
--> Tap:D)
5758
5859
Creates a new tap (a kind of subscription if you will), in addition to all
@@ -69,7 +70,14 @@ block will then reach its end).
6970
The C<&quit> callback is called if the tap is on a supply block which exits with an error. It is also
7071
called if the C<quit> method is invoked on the parent C<Supplier> (in the case of a supply block any
7172
one C<Supplier> quitting with an uncaught exception will call the C<&quit> callback as the block will
72-
exit with an error).
73+
exit with an error). The error is passed as a parameter to the callback.
74+
75+
The C<&tap> callback is called once the L<Tap|/type/Tap> object is created,
76+
which is passed as a parameter to the callback. The callback is called ahead of
77+
C<emit>/C<done>/C<quit>, providing a reliable way to get the C<Tap> object. One
78+
case where this is useful is when the C<Supply> begins emitting values
79+
synchronously, since the call to C<.tap> won't return the C<Tap> object until
80+
it is done emitting, preventing it from being stopped if needed.
7381
7482
Method C<tap> returns an object of type L<Tap|/type/Tap>, on which you can
7583
call the C<close> method to cancel the subscription.

0 commit comments

Comments
 (0)