Skip to content

Commit c1510f6

Browse files
committed
Add preliminary doc for Supply.share
1 parent 592e4a5 commit c1510f6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Type/Supply.pod

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,21 @@ Creates an on-demand supply from the values passed to this method.
217217
$s.tap(&say); # 1\n2\n3\n
218218
$s.done;
219219
220+
=head2 method share
221+
222+
method share(Supply:D:) returns Supply:D
223+
224+
my $s = Supply.from-list(^100000).share;
225+
my @first;
226+
$s.tap: { @first.push($_) };
227+
my @second;
228+
$s.tap: { @second.push($_) };
229+
say @first + @second;
230+
231+
Creates a live supply from an on-demand supply, thus making it possible to
232+
share the values of the on-demand supply on multiple taps, instead of each
233+
tap seeing all values from the on-demand supply.
234+
220235
=head2 method flat
221236
222237
method flat(Supply:D:) returns Supply:D

0 commit comments

Comments
 (0)