-
Fix the cancellation propagation behavior of
Promise.Resolver.resolve(with:)
and theflatMap
family of methods. Previously, requesting cancellation of the promise associated with the resolver (forresolve(with:)
, or the returned promise for theflatMap
family) would immediately request cancellation of the upstream promise even if the upstream promise had other children. The new behavior fixes this such that it participates in automatic cancellation propagation just like any other child promise (#54). -
Slightly optimize stack usage when chaining one promise to another.
-
Avoid using stack space for chained promises that don't involve a callback. For example, when the promise returned from a
flatMap(on:token:_:)
resolves it will resolve the outer promise without using additional stack frames. You can think of it like tail calling functions. This affects not justflatMap
but also operations such astap()
,ignoringCancel()
, and more. This also applies to Obj-C (withTWLPromise
).Note: This does not affect the variants that implicitly upcast from some
E: Swift.Error
toSwift.Error
such astryFlatMap(on:token:_:)
. -
Change cancellation propagation behavior of
onCancel
. Liketap
, it doesn't prevent automatic cancellation propagation if the parent has other children and all other children request cancellation. Unliketap
, requesting cancellation ofonCancel
when there are no other children will propagate cancellation to the parent. The motivation here is attaching anonCancel
observer shouldn't prevent cancellation that would otherwise occur, but when it's the only child it should behave like the other standard observers (#57). -
Add method
Promise.makeChild()
. This returns a new child of the receiver that adopts the receiver's value and propagates cancellation like any other observer. The purpose here is to be used when handing back multiple children of one parent to callers, as handing back the parent means any one caller can cancel it without the other callers' participation. This is particularly useful in conjunction withpropagatingCancellation(on:cancelRequested:)
(#56).