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, otherwisenil.Declaration
Swift
public var value: Value? { get } -
Returns the contained error if the result is
.error, otherwisenil.Declaration
Swift
public var error: Error? { get } -
Returns
trueif the result is.cancelled, otherwisefalse.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>
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Declaration
Swift
public static func == (lhs: PromiseResult, rhs: PromiseResult) -> BoolParameters
lhsA value to compare.
rhsAnother value to compare.
-
Returns a Boolean value indicating whether two values are not equal.
Inequality is the inverse of equality. For any values
aandb,a != bimplies thata == bisfalse.This is the default implementation of the not-equal-to operator (
!=) for any type that conforms toEquatable.Declaration
Swift
public static func != (lhs: PromiseResult, rhs: PromiseResult) -> BoolParameters
lhsA value to compare.
rhsAnother value to compare.
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Declaration
Swift
public func encode(to encoder: Encoder) throws
-
Declaration
Swift
public init(from decoder: Decoder) throws
-
Returns a
PromiseResultfrom aResult.Declaration
Swift
public init(_ result: Result<Value, Error>)
View on GitHub
PromiseResult Enumeration Reference