Course of Raku / Functional, concurrent, reactive, and web programming / Reactive programming / await / Exercises / Await a supply
Solution: Await a supply
Here is a possible solution to the task.
Code
my @values;
react {
whenever Supply.from-list('a', 'b', 'c') {
@values.push($_);
}
}
say @values.join('-');🦋 You can find the source code in the file await-a-supply.raku.
Output
a-b-cComments
The
reactblock waits until the supply is done, so@valuesholds all three strings, in order, afterwards..join('-')glues them with dashes, givinga-b-c. Thereactblock gave us the same “wait until complete” guarantee thatawaitgives for a promise.