DownloadTask
public struct DownloadTask
Represents a task of an image downloading process.
-
The
SessionDataTask
object bounded to this download task. MultipleDownloadTask
s could refer to a samesessionTask
. This is an optimization in Kingfisher to prevent multiple downloading task for the same URL resource at the same time.When you
cancel
aDownloadTask
, thisSessionDataTask
and its cancel token will be pass through. You can use them to identify the cancelled task.Declaration
Swift
public let sessionTask: SessionDataTask
-
The cancel token which is used to cancel the task. This is only for identify the task when it is cancelled. To cancel a
DownloadTask
, usecancel
instead.Declaration
Swift
public let cancelToken: SessionDataTask.CancelToken
-
Cancel this task if it is running. It will do nothing if this task is not running.
Note
In Kingfisher, there is an optimization to prevent starting another download task if the target URL is being downloading. However, even when internally no new session task created, aDownloadTask
will be still created and returned when you call related methods, but it will share the session downloading task with a previous task. In this case, if multipleDownloadTask
s share a single session download task, cancelling aDownloadTask
does not affect otherDownloadTask
s.If you need to cancel all
DownloadTask
s of a url, useImageDownloader.cancel(url:)
. If you need to cancel all downloading tasks of anImageDownloader
, useImageDownloader.cancelAll()
.Declaration
Swift
public func cancel()