Documentation for method anyof

Documentation for method anyof, assembled from the following types:

class Promise

From Promise

(Promise) method anyof

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

Returns a new promise that will be kept as soon as any of the promises passed as arguments is kept or broken. The result of the completed Promise is not reflected in the result of the returned promise which will always be Kept.

You can use this to wait at most a number of seconds for a promise:

my $timeout = 5;
await Promise.anyof($timeout),
    start {
        # do a potentially long-running calculation here