Skip to content

Commit df91521

Browse files
authored
Merge pull request #2390 from MorayJ/supply-fix
Supply fix
2 parents 1c00ac5 + 2b5d57d commit df91521

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

doc/Type/Supply.pod6

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ It is a thread-safe implementation of the
1414
L<Observer Pattern|https://en.wikipedia.org/wiki/Observer_pattern>,
1515
and central to supporting reactive programming in Perl 6.
1616
17-
1817
There are two types of Supplies: C<live> and C<on demand>. When tapping into a
1918
C<live> supply, the tap will only see values that are flowing through the
2019
supply B<after> the tap has been created. Such supplies are normally infinite
@@ -29,7 +28,7 @@ time it is tapped. If the tap is closed, the timer simply stops emitting values
2928
to that tap.
3029
3130
A C<live> C<Supply> is obtained from the L<Supplier|/type/Supplier>
32-
factory method C<Supply>. New values are emitted by calling C<emit> on
31+
factory method C<Supply>. New values are emitted by calling C<emit> on
3332
the C<Supplier> object.
3433
3534
my $supplier = Supplier.new;
@@ -60,13 +59,17 @@ Creates a new tap (a kind of subscription if you will), in addition to all
6059
existing taps. The first positional argument is a piece of code that will be
6160
called when a new value becomes available through the C<emit> call.
6261
63-
The C<&done> callback is called when the C<done> method on the supply is
64-
called, indicating the end of life of the channel. For a C<live> supply the
65-
C<done> routine will be called on the parent C<Supplier>.
66-
67-
The C<&quit> callback is called when the C<quit> method on the supply is
68-
called, indicating an erroneous termination of the supply. For a C<live>
69-
supply the C<quit> routine will be called on the parent C<Supplier>
62+
The C<&done> callback can be called in a number of cases: if a supply block is being tapped, when a C<done> routine is reached;
63+
if a supply block is being tapped, it will be automatically triggered if the supply block reaches the end;
64+
if the C<done> method is called on the parent C<Supplier>
65+
(in the case of a supply block, if there are multiple Suppliers referenced by C<whenever>, they must
66+
all have their C<done> method invoked for this to trigger the C<&done> callback of the tap as the
67+
block will then reach its end).
68+
69+
The C<&quit> callback is called if the tap is on a supply block which exits with an error. It is also
70+
called if the C<quit> method is invoked on the parent C<Supplier> (in the case of a supply block any
71+
one C<Supplier> quitting with an uncaught exception will call the C<&quit> callback as the block will
72+
exit with an error).
7073
7174
Method C<tap> returns an object of type L<Tap|/type/Tap>, on which you can
7275
call the C<close> method to cancel the subscription.

0 commit comments

Comments
 (0)