v1.2.0
-
Add
PromiseContext.nowOr(context)
(+[TWLContext nowOrContext:]
in Obj-C) that runs the callback synchronously when registered if the promise has already resolved, otherwise registers the callback to run oncontext
. This can be used to replace code that previously would have required checkingpromise.result
prior to registering the callback (#34).For example:
networkImagePromise.then(on: .nowOr(.main), { [weak button] (image) in button?.setImage(image, for: .normal) })
-
Add
Promise.Resolver.hasRequestedCancel
(TWLResolver.cancelRequested
in Obj-C) that returnstrue
if the promise has been requested to cancel or is already cancelled, orfalse
if it hasn't been requested to cancel or is fulfilled or rejected. This can be used when a promise initializer takes significant time in a manner not easily interrupted by anonRequestCancel
handler (#47). -
Change
Promise.timeout
's default context from.auto
to.nowOr(.auto)
. This behaves the same as.auto
in most cases, except if the receiver has already been resolved this will cause the returned promise to likewise already be resolved (#50). -
Ensure
when(first:cancelRemaining:)
returns an already-cancelled promise if all input promises were previously cancelled, instead of cancelling the returned promise asynchronously (#51). -
Ensure
when(fulfilled:qos:cancelOnFailure:)
returns an already-resolved promise if either all input promises were previously fulfilled or any input promise was previously rejected or cancelled (#52).