PromiseCancellable

public struct PromiseCancellable

A type that can be used to cancel a promise without holding onto the full promise.

In particular, this acts like a weak reference, allowing for cancelling the promise without creating a retain cycle. Promise retain cycles normally break themselves anyway when the promise is resolved, but a misbehaving promise body may drop the resolver without ever resolving the promise. If the Promise has no more references to it this automatically cancels the promise, but a retain cycle prevents this.

This is returned from Promise.cancellable.

  • Requests cancellation of the promise this PromiseCancellable was created from.

    Declaration

    Swift

    public func requestCancel()