Downloadable

public protocol Downloadable: ADownloadable, Configurable, DownloadResponseSerializable

Represents a Downloadable for Restofire.

protocol HTTPBinDownloadService: Downloadable {

    var path: String? = "bytes/\(4 * 1024 * 1024)"
    var destination: DownloadFileDestination?

    init(destination: @escaping DownloadFileDestination) {
        self.destination = destination
    }

}
  • request(_:didCompleteWithValue:) Default implementation

    Called when the Request succeeds.

    Default Implementation

    Does Nothing

    Declaration

    Swift

    func request(_ request: DownloadOperation<Self>, didCompleteWithValue value: Response)

    Parameters

    request

    The Alamofire.DownloadRequest

    value

    The Response

  • request(_:didFailWithError:) Default implementation

    Called when the Request fails

    Default Implementation

    Does Nothing

    Declaration

    Swift

    func request(_ request: DownloadOperation<Self>, didFailWithError error: Error)

    Parameters

    request

    The Alamofire.DownloadRequest

    error

    The Error

  • execute(completionHandler:) Extension method

    Creates a DownloadOperation for the specified Requestable object and asynchronously executes it.

    Declaration

    Swift

    public func execute(completionHandler: ((DownloadResponse<Response>) -> Void)? = nil) -> DownloadOperation<Self>

    Parameters

    completionHandler

    A closure to be executed once the download has finished. nil by default.

    Return Value

    The created DownloadOperation.

  • Creates a DownloadOperation for the specified Requestable object and asynchronously executes it.

    Declaration

    Swift

    public func execute(request: @autoclosure @escaping () -> DownloadRequest, completionHandler: ((DownloadResponse<Response>) -> Void)? = nil) -> DownloadOperation<Self>

    Parameters

    request

    A download request instance

    completionHandler

    A closure to be executed once the download has finished. nil by default.

    Return Value

    The created DownloadOperation.