Quick actions

cmd+k|ctrl+k

Navigation

Languages

A+ Promise

Snippet info

Language

Raku

Visibility

public

Author

fernando-correa

Created

2025-05-29T10:41:19.314199Z

Updated

2025-05-29T11:18:24.646169Z

role APlus {
    method andthen(&block) {
        nextwith -> Promise $p {
            my \res = block $p.result;
            do if res ~~ Awaitable {
                await res
            } else {
                res
            }
        }
    }
}
sub a-start(&block) { (start block) does APlus }

say await (a-start { 1 }).andthen(-> Int $i { a-start { $i + 1 }})
INFO