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(_:didDownloadProgress:)
Default implementationCalled when the Request updates with download progress.
Default Implementation
Does Nothing
Declaration
Swift
func request(_ request: DownloadRequest, didDownloadProgress progress: Progress)
Parameters
request
The Alamofire.DownloadRequest
progress
The Progress
-
request(_:didCompleteWithValue:)
Default implementationCalled when the Request succeeds.
Default Implementation
Does Nothing
Declaration
Swift
func request(_ request: DownloadRequest, didCompleteWithValue value: Response)
Parameters
request
The Alamofire.DownloadRequest
value
The Response
-
request(_:didFailWithError:)
Default implementationCalled when the Request fails
Default Implementation
Does Nothing
Declaration
Swift
func request(_ request: DownloadRequest, didFailWithError error: Error)
Parameters
request
The Alamofire.DownloadRequest
error
The Error
-
response(_:)
Extension methodCreates a
DownloadOperation
for the specifiedRequestable
object and asynchronously executes it.Declaration
Swift
public func response(_ 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
.