PromiseResult

public enum PromiseResult<Value, Error>
extension PromiseResult: Equatable where Value: Equatable, Error: Equatable
extension PromiseResult: Hashable where Value: Hashable, Error: Hashable
extension PromiseResult: Encodable where Value: Encodable, Error: Encodable
extension PromiseResult: Decodable where Value: Decodable, Error: Decodable

The result of a resolved promise.

  • The value the promise was fulfilled with.

    Declaration

    Swift

    case value(Value)
  • The error the promise was rejected with.

    Declaration

    Swift

    case error(Error)
  • The promise was cancelled.

    Declaration

    Swift

    case cancelled
  • Returns the contained value if the result is .value, otherwise nil.

    Declaration

    Swift

    public var value: Value? { get }
  • Returns the contained error if the result is .error, otherwise nil.

    Declaration

    Swift

    public var error: Error? { get }
  • Returns true if the result is .cancelled, otherwise false.

    Declaration

    Swift

    public var isCancelled: Bool { get }
  • Maps a successful result through a block and returns the new result.

    Declaration

    Swift

    public func map<T>(_ transform: (Value) throws -> T) rethrows -> PromiseResult<T, Error>
  • Maps a rejected result through a block and returns the new result.

    Declaration

    Swift

    public func mapError<E>(_ transform: (Error) throws -> E) rethrows -> PromiseResult<Value, E>
  • Maps a successful result through a block and returns the new result.

    Declaration

    Swift

    public func flatMap<T>(_ transform: (Value) throws -> PromiseResult<T, Error>) rethrows -> PromiseResult<T, Error>
  • Maps a rejected result through a block and returns the new result.

    Declaration

    Swift

    public func flatMapError<E>(_ transform: (Error) throws -> PromiseResult<Value, E>) rethrows -> PromiseResult<Value, E>

Available where Value: Equatable, Error: Equatable

  • 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: PromiseResult, rhs: PromiseResult) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

  • Returns a Boolean value indicating whether two values are not equal.

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

    This is the default implementation of the not-equal-to operator (!=) for any type that conforms to Equatable.

    Declaration

    Swift

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

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

Available where Value: Hashable, Error: Hashable

  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)

Available where Value: Encodable, Error: Encodable

  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws

Available where Value: Decodable, Error: Decodable

  • Declaration

    Swift

    public init(from decoder: Decoder) throws

Available where Error: Swift.Error

  • Returns a PromiseResult from a Result.

    Declaration

    Swift

    public init(_ result: Result<Value, Error>)