Skip to content

Commit c5191f6

Browse files
committed
Add factory methods "kept" and "broken" to Promise
1 parent 21e290b commit c5191f6

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

doc/Type/Promise.pod6

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ combining promises, and waiting for results.
1919
say $p.status; # OUTPUT: «Kept␤»
2020
2121
There are two typical scenarios for using promises. The first is to use a
22-
factory method (C<start>, C<in>, C<anyof>, C<allof>) on the type object; those
23-
will make sure that the promise is automatically kept or broken for you, and
24-
you can't call C<break> or C<keep> on these promises yourself.
22+
factory method (C<start>, C<in>, C<at>, C<anyof>, C<allof>, C<kept>, C<broken>)
23+
on the type object; those will make sure that the promise is automatically kept
24+
or broken for you, and you can't call C<break> or C<keep> on these promises
25+
yourself.
2526
2627
The second is to create your promises yourself with C<Promise.new>. If you
2728
want to ensure that only your code can keep or break the promise, you can use
@@ -99,6 +100,22 @@ given as an L<Instant> or equivalent L<Numeric>—or as soon as possible after i
99100
If the given time is in the past, it will be treated as L<now> (i.e.
100101
L<keeping|/routine/keep> the returned L<Promise> right away).
101102
103+
=head2 method kept
104+
105+
multi method kept(Promise:U: --> Promise:D)
106+
multi method kept(Promise:U: \result --> Promise:D)
107+
108+
Returns a new promise that is already kept, either with the given value,
109+
or with the default value True.
110+
111+
=head2 method broken
112+
113+
multi method broken(Promise:U: --> Promise:D)
114+
multi method broken(Promise:U: \exception --> Promise:D)
115+
116+
Returns a new promise that is already broken, either with the given value,
117+
or with the default value "Died".
118+
102119
=head2 method allof
103120
104121
method allof(Promise:U: *@promises --> Promise:D)

0 commit comments

Comments
 (0)