Tomorrowland v1.4.0 Release Notes
Release Date: 2020-07-28 // over 4 years ago-
๐ 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).
Previous changes from v1.3.0
-
- ๐ Add
PromiseContext.isExecutingNow
(TWLPromiseContext.isExecutingNow
in Obj-C) that returnstrue
if accessed from within a callback registered with.nowOr(_:)
and executing synchronously, orfalse
otherwise. If accessed from within a callback (orPromise.init(on:_:)
) registered with.immediate
and running synchronously, it inherits the surrounding scope'sPromiseContext.isExecutingNow
flag. This is intended to allowPromise(on: .immediate, { โฆ })
to query the surrounding scope's flag (#53). - โ Add convenience methods to Obj-C for doing then+catch together, as this is a common pattern and chaining Obj-C methods is a little awkward (#45).
- ๐ Change
Promise.timeout
's default context to.nowOr(.auto)
for theError
overload as well. - ๐ Change the behavior of
Promise.timeout(on:delay:)
when thedelay
is less than or equal to zero, thecontext
is.immediate
or.nowOr(_:)
, and the upstream promise hasn't resolved yet. Previously the timeout would occur asynchronously and the upstream promise would get a chance to race the timeout. With the new behavior the timeout occurs synchronously (#49).
- ๐ Add