Skip to content

Commit 8b677e1

Browse files
authored
Use the TV/Netflix analogy on Supplies also on the dedicated page /type/Supply. (Plus one other small proposal) (#4622)
* Update control.rakudoc .char --> .chars, as that's the name of the char counting routine * Copy the useful TV/Netflix analogy from /language/concurrency * Update Supply.rakudoc: change "Netflix" → "a video streaming service" * Update Supply.rakudoc: whitespace * Update Supply.rakudoc: whitespace
1 parent 9bfa3cc commit 8b677e1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

doc/Language/control.rakudoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ tested again.
991991
say $i;
992992
}
993993

994-
my @str = "However Long".comb; # Our very own .char routine:
994+
my @str = "However Long".comb; # Our very own .chars routine:
995995
loop (my $l = 0;;) { # Declare $l in outer scope
996996
last if !@str[$l++] # and count chars until we hit
997997
} # an undefined element (Any)

doc/Type/Supply.rakudoc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ It is a thread-safe implementation of the
1515
L<Observer Pattern|https://en.wikipedia.org/wiki/Observer_pattern>,
1616
and central to supporting reactive programming in Raku.
1717

18-
There are two types of Supplies: C<live> and C<on demand>. When tapping into a
18+
There are two types of Supplies: C<live> and C<on demand>. A C<live>
19+
supply is like a TV broadcast: those who tune in don't get previously emitted
20+
values. An C<on-demand> broadcast is like a video streaming service:
21+
everyone who starts streaming a movie (taps a supply),
22+
always starts it from the beginning (gets all the values),
23+
regardless of how many people are watching it right now.
24+
25+
Thus, when tapping into a
1926
C<live> supply, the tap will only see values that are flowing through the
2027
supply B<after> the tap has been created. Such supplies are normally infinite
2128
in nature, such as mouse movements. Closing such a tap does not stop mouse
@@ -26,7 +33,8 @@ A tap on an C<on demand> supply will initiate the production of values, and
2633
tapping the supply again may result in a new set of values. For example,
2734
C<Supply.interval> produces a fresh timer with the appropriate interval each
2835
time it is tapped. If the tap is closed, the timer simply stops emitting values
29-
to that tap.
36+
to that tap. Note that no history is kept for C<on-demand> supplies, instead,
37+
the C<supply> block is run for each tap of the supply.
3038

3139
A C<live> C<Supply> is obtained from the L<C<Supplier>|/type/Supplier>
3240
factory method C<Supply>. New values are emitted by calling C<emit> on

0 commit comments

Comments
 (0)