PromiseInvalidationToken
public struct PromiseInvalidationToken : CustomStringConvertible, CustomDebugStringConvertible
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. Iffalse
it won’t invalidate unless you explicitly callinvalidate()
. This is primarily useful in conjunction withrequestCancelOnInvalidate(_:)
so you don’t have to cancel your promises when the object that owns the invalidation token deinits. -
Invalidates the token and cancels any associated promises.
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. withmap(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()
-
Cancels any associated promises without invalidating the token.
After invoking this method, any promises that have been registered with
requestCancelOnInvalidate(_:)
will be requested to cancel.Declaration
Swift
public func cancelWithoutInvalidating()
-
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
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public var debugDescription: String { get }
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Swift
public static func == (lhs: PromiseInvalidationToken, rhs: PromiseInvalidationToken) -> Bool
Parameters
lhs
A value to compare.
rhs
Another value to compare.
-
Declaration
Swift
public func hash(into hasher: inout Hasher)