Skip to content

Commit 48e20f4

Browse files
committed
First batch of documentation of Supply methods
1 parent e47c510 commit 48e20f4

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

lib/Type/Supply.pod

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ Waits until the supply is done (in which case it returns C<True>) or C<quit>
202202
say "Done";
203203
await $p;
204204
205-
206205
=head2 method list
207206
208207
method list(Supply:D:) returns List:D
@@ -214,7 +213,7 @@ since the C<list> call.
214213
215214
method interval(Supply:U: $interval, $delay = 0)
216215
217-
Creates a new interval that fires an event every C<$interval> seconds,
216+
Creates a supply that fires an event every C<$interval> seconds,
218217
starting C<$delay> seconds from the call. The event payload is an integer,
219218
starting from 0 at the first event, and is increment by one for each event.
220219
@@ -242,6 +241,66 @@ with the element transformed through C<&mapper>;
242241
$double.tap(&say);
243242
$all.emit(4); # 8
244243
244+
=head2 method batch
245+
246+
method batch(Supply:D: :$elems, :$seconds)
247+
248+
Creates a new supply that batches the values of the given Supply by either
249+
the number of elements (using :elems) or the maximum number of seconds
250+
(using the :seconds) or both. Remaining values are batched into a final
251+
emission when the supply is done.
252+
253+
=head2 method elems
254+
255+
method elems(Supply:D: $seconds?)
256+
257+
Creates a new supply in which changes to the number of elements seen are
258+
emitted. It optionally also takes an interval (in seconds) if you only want
259+
to be updated every so many seconds.
260+
261+
=head2 method rotor
262+
263+
method rotor(Supply:D: @cycle)
264+
265+
Creates a "rotoring" supply with the same semantics as List.rotor.
266+
267+
=head2 method delayed
268+
269+
method delayed(Supply:D: $seconds)
270+
271+
Creates a new supply in which all values are emitted with the given delay in
272+
seconds.
273+
274+
=head2 method stable
275+
276+
method stable(Supply:D: $seconds, :$scheduler)
277+
278+
Creates a new supply that only passes on a value if it wasn't superseded by
279+
another value in the given time (in seconds). Optionally uses another
280+
scheduler than the default scheduler, using the :scheduler parameter.
281+
282+
=head2 method reduce
283+
284+
method reduce(Supply:D: {...} )
285+
286+
Creates a "reducing" supply with the same semantics as List.reduce.
287+
288+
=head2 method lines
289+
290+
method lines(Supply:D: :$chomp = True )
291+
292+
Creates a supply that will emit the characters coming in line by line from a
293+
supply that's usually created by some asynchronous I/O operation. The optional
294+
:chomp parameter indicates whether to remove line separators: the default is
295+
True.
296+
297+
=head2 method words
298+
299+
method words(Supply:D:)
300+
301+
Creates a supply that will emit the characters coming in word for word from a
302+
supply that's usually created by some asynchronous I/O operation.
303+
245304
=head2 method schedule-on
246305
247306
method schedule-on(Supply:D: $scheduler)

0 commit comments

Comments
 (0)