In PromiseĀ§

See primary documentation in context for method then

method then(Promise:D: &code)

Schedules a piece of code to be run after the invocant has been kept or broken, and returns a new promise for this computation. In other words, creates a chained promise. The Promise is passed as an argument to the &code.

# Use code only 
my $timer = Promise.in(2);
my $after = $timer.then({ say '2 seconds are over!''result' });
say $after.result;
# OUTPUT: Ā«2 seconds are overā¤resultā¤Ā» 
 
# Interact with original Promise 
my $after = Promise.in(2).then(-> $p { say $p.statussay '2 seconds are over!''result' });
say $after.result;
# OUTPUT: Ā«Keptā¤2 seconds are overā¤resultā¤Ā»