Documentation for method allof

Documentation for method allof, assembled from the following types:

class Promise

From Promise

(Promise) method allof

method allof(Promise:U: *@promises --> Promise:D)

Returns a new promise that will be kept when all the promises passed as arguments are kept or broken. The result of the individual Promises is not reflected in the result of the returned promise: it simply indicates that all the promises have been completed in some way. If the results of the individual promises are important then they should be inspected after the allof promise is kept.

In the following requesting the result of a broken promise will case the original Exception to be thrown. (You may need to run it several times to see the exception.)

my @promises;
for 1..5 -> $t {
    push @promisesstart {
        sleep $t;
my $all-done = Promise.allof(@promises);
await $all-done;
say "Promises kept so we get to live another day!";