method at

Documentation for method at assembled from the following types:

class Promise

From Promise

(Promise) method at

method at(Promise:U: $at:$scheduler = $*SCHEDULER --> Promise:D)

Creates a new Promise that will be kept $at the given time—which is given as an Instant or equivalent Numeric—or as soon as possible after it.

my $p = + 2).then({ say "2 seconds later" });
# do other stuff here 
await $p;   # wait here until the 2 seconds are over

If the given time is in the past, it will be treated as now (i.e. keeping the returned Promise right away).

Please note that situations like these are often more clearly handled with a react and whenever block.