ImageDataProvider
public protocol ImageDataProvider
Represents a data provider to provide image data to Kingfisher when setting with
Source.provider
source. Compared to Source.network
member, it gives a chance
to load some image data in your own way, as long as you can provide the data
representation for the image.
-
The key used in cache.
Declaration
Swift
var cacheKey: String { get }
-
Provides the data which represents image. Kingfisher uses the data you pass in the handler to process images and caches it for later use.
Note
If the
handler
is called with a.failure
with error, adataProviderError
ofImageSettingErrorReason
will be finally thrown out to you as theKingfisherError
from the framework.Declaration
Swift
func data(handler: @escaping (Result<Data, Error>) -> Void)
Parameters
handler
The handler you should call when you prepared your data. If the data is loaded successfully, call the handler with a
.success
with the data associated. Otherwise, call it with a.failure
and pass the error.