AnyTask
public class AnyTask<T> : Task
An AnyTask can be used as a generic Task object. You have to pass it a execute block when it’s initialized
and that will be called when it’s time to execute the task.
AnyTasks schedules execution blocks on TaskManager.shared.
-
Alias of the “successful” return value of your execution block
Declaration
Swift
public typealias SuccessValue = T -
Initialize the AnyTask with an execution block that is given a “done” callback that must be called with a
Task.CompletionCallbackDeclaration
Swift
@discardableResult public init(timeout: DispatchTimeInterval? = nil, execute: @escaping (@escaping AnyTask.CompletionCallback) -> Void)Parameters
timeoutafter how long the task timeout
executethe execution block.
-
Initialize the AnyTask with an execution block that just returns a type T and may throw
Declaration
Swift
@discardableResult public convenience init(timeout: DispatchTimeInterval? = nil, execute: @escaping () throws -> T)Parameters
timeoutafter how long the task timeout
executethe execution block.
-
Initialize the AnyTask with an execution block that just returns a type T
Declaration
Swift
@discardableResult public convenience init(timeout: DispatchTimeInterval? = nil, execute: @escaping () -> T)Parameters
timeoutafter how long the task timeout
executethe execution block.
-
Initialize the AnyTask with another
Taskobject. TheTask.SuccessValuemust match the type T of this AnyTaskDeclaration
Swift
@discardableResult public convenience init<U>(fromTask task: U, timeout: DispatchTimeInterval? = nil) where T == U.SuccessValue, U : TaskParameters
taskThe
Taskobject that this will wraptimeoutSpecify if you wan to overwrites
Task.timeout. -
The timeout passed in the initializer
Declaration
Swift
public let timeout: DispatchTimeInterval? -
The
Task.executefunction calls the execution block was given to an initilzerDeclaration
Swift
public func execute(completion: @escaping CompletionCallback)
View on GitHub
AnyTask Class Reference