File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -221,16 +221,16 @@ Creates an on-demand supply from the values passed to this method.
221
221
222
222
method share(Supply:D:) returns Supply:D
223
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
224
Creates a live supply from an on-demand supply, thus making it possible to
232
225
share the values of the on-demand supply on multiple taps, instead of each
233
- tap seeing all values from the on-demand supply.
226
+ tap seeing its own copy of all values from the on-demand supply.
227
+
228
+ # this says in turn: "first 1" "first 2" "second 2" "first 3" "second 3"
229
+ my $s = Supply.interval(1).share;
230
+ $s.tap: { "first $_".say };
231
+ sleep 1.1;
232
+ $s.tap: { "second $_".say };
233
+ sleep 2
234
234
235
235
= head2 method flat
236
236
You can’t perform that action at this time.
0 commit comments