PromiseInvalidationToken

public struct PromiseInvalidationToken

An invalidation token that can be used to cancel callbacks registered to a Promise.

  • Creates and returns a new PromiseInvalidationToken.

    Declaration

    Swift

    public init(invalidateOnDeinit: Bool = true)

    Parameters

    invalidateOnDeinit

    The default value of true means the token will automatically be invalidated when it deinits. If false it won’t invalidate unless you explicitly call invalidate(). This is primarily useful in conjunction with requestCancelOnInvalidate(_:) so you don’t have to cancel your promises when the object that owns the invalidation token deinits.

  • After invoking this method, all Promise callbacks registered with this token will be suppressed. Any callbacks whose return value is used for a subsequent promise (e.g. with then(on:token:_:)) will result in a cancelled promise instead if the callback would otherwise have been executed.

    In addition, any promises that have been registered with requestCancelOnInvalidate(_:) will be requested to cancel.

    Declaration

    Swift

    public func invalidate()
  • Registers a Promise to be requested to cancel automatically when the token is invalidated.

    Declaration

    Swift

    public func requestCancelOnInvalidate<V, E>(_ promise: Promise<V, E>)
  • Registers an ObjCPromise to be requested to cancel automatically when the token is invalidated.

    Declaration

    Swift

    public func requestCancelOnInvalidate<V, E>(_ promise: ObjCPromise<V, E>) where V : AnyObject, E : AnyObject
  • Returns a Boolean value indicating whether two values are equal.

    Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

    Declaration

    Swift

    public static func == (lhs: PromiseInvalidationToken, rhs: PromiseInvalidationToken) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

  • Declaration

    Swift

    public var hashValue: Int { get }