Completion
public enum Completion<T>
Defines a an enumeration that can be used to complete a Promise/Future.
Success(T): The Future should complete with a
FutureResult.Success(T)
Fail(ErrorType): The Future should complete with a
FutureResult.Fail(ErrorType)
Cancelled:
The Future should complete with withFutureResult.Cancelled
.CompleteUsing(Future
):
The Future should be completed with the result of a another dependent Future, when the dependent Future completes.If The Future receives a cancelation request, than the cancellation request will be forwarded to the depedent future.
-
returns a .Fail(FutureNSError) with a simple error string message.
Declaration
Swift
public init(failWithErrorMessage : String)
-
converts an NSException into an NSError. useful for generic Objective-C excecptions into a Future
Declaration
Swift
public init(exception ex:NSException)
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
get the Completion state for a completed state. It’s easier to create a switch statement on a completion.state, rather than the completion itself (since a completion block will never be sent a .CompleteUsing).
Declaration
Swift
public func asResult() -> FutureResult<T>
-
make sure this enum is a .Success before calling
result
. Do a check ‘completion.state {}` or .isFail() first.Declaration
Swift
public var value : T!
-
make sure this enum is a .Fail before calling
result
. Use a switch or check .isError() first.Declaration
Swift
public var error : ErrorType!
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
convert this completion of type Completion
into another type Completion .may fail to compile if T is not convertable into S using
`as!`
works iff the following code works:
‘let t : T`
‘let s = t as! S’
- example:
let c : Complete<Int> = .Success(5)
let c2 : Complete<Int32> = c.mapAs()
assert(c2.result == Int32(5))
you will need to formally declare the type of the new variable, in order for Swift to perform the correct conversion.
Declaration
Swift
public func map<S>(block:(T) throws -> S) -> Completion<S>
-
convert this completion of type Completion
into another type Completion .may fail to compile if T is not convertable into S using
`as!`
works iff the following code works:
‘let t : T`
‘let s = t as! S’
- example:
let c : Complete<Int> = .Success(5)
let c2 : Complete<Int32> = c.mapAs()
assert(c2.result == Int32(5))
you will need to formally declare the type of the new variable, in order for Swift to perform the correct conversion.
Declaration
Swift
public func mapAs<S>() -> Completion<S>
-
convert this completion of type
Completion<T>
into another typeCompletion<S?>
.WARNING: if
T as! S
isn’t legal, than all Success values may be converted to nil - example:let c : Complete
= .Success( 5
) let c2 : Complete<[Int]?> = c.convertOptional() assert(c2.result == nil)you will need to formally declare the type of the new variable, in order for Swift to perform the correct conversion.
Declaration
Swift
public func convertOptional<S>() -> Completion<S?>
Return Value
a new result of type Completion
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>
-
Undocumented
Declaration
Swift
public enum Completion<T>