Tomorrowland v1.2.0 Release Notes

Release Date: 2020-05-22 // almost 4 years ago

    โž• 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 on context. This can be used to replace code that previously would have required checking promise.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 returns true if the promise has been requested to cancel or is already cancelled, or false 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 an onRequestCancel 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).