Nuke Documentation

Protocol Image​Pipeline​Delegate

public protocol ImagePipelineDelegate: AnyObject  

A delegate that allows you to customize the pipleine on a per-request basis.

ImagePipelineDelegate ImagePipelineDelegate AnyObject AnyObject ImagePipelineDelegate->AnyObject ImagePipelineDefaultDelegate ImagePipelineDefaultDelegate ImagePipelineDefaultDelegate->ImagePipelineDelegate

Conforms To

AnyObject

Default Implementations

data​Loader(for:​pipeline:​)

func dataLoader(for request: ImageRequest, pipeline: ImagePipeline) -> DataLoading  

data​Cache(for:​pipeline:​)

func dataCache(for request: ImageRequest, pipeline: ImagePipeline) -> DataCaching?  

cache​Key(for:​pipeline:​)

func cacheKey(for request: ImageRequest, pipeline: ImagePipeline) -> String?  

will​Cache(data:​image:​for:​pipeline:​completion:​)

func willCache(data: Data, image: ImageContainer?, for request: ImageRequest, pipeline: ImagePipeline, completion: @escaping (Data?) -> Void)  

pipeline(_:​image​Task:​did​Receive​Event:​)

func pipeline(_ pipeline: ImagePipeline, imageTask: ImageTask, didReceiveEvent event: ImageTaskEvent)  

Requirements

data​Loader(for:​pipeline:​)

func dataLoader(for request: ImageRequest, pipeline: ImagePipeline) -> DataLoading

Returns data loader for the given request.

data​Cache(for:​pipeline:​)

func dataCache(for request: ImageRequest, pipeline: ImagePipeline) -> DataCaching? 

Retuns disk cache for the given request. Return nil to prevent cache reads and writes.

image​Decoder(for:​pipeline:​)

func imageDecoder(for context: ImageDecodingContext, pipeline: ImagePipeline) -> ImageDecoding? 

Returns image decoder for the given context.

image​Encoder(for:​pipeline:​)

func imageEncoder(for context: ImageEncodingContext, pipeline: ImagePipeline) -> ImageEncoding

Returns image encoder for the given context.

cache​Key(for:​pipeline:​)

func cacheKey(for request: ImageRequest, pipeline: ImagePipeline) -> String? 

Returns a cache key identifying the image produced for the given request (including image processors).

Return nil to use a default key.

will​Cache(data:​image:​for:​pipeline:​completion:​)

func willCache(data: Data, image: ImageContainer?, for request: ImageRequest, pipeline: ImagePipeline, completion: @escaping (Data?) -> Void) 

Gets called when the pipeline is about to save data for the given request. The implementation must call the completion closure passing non-nil data to enable caching or nil to prevent it.

This method calls only if the request parameters and data caching policy of the pipeline already allow caching.

Parameters

data Data

Either the original data or the encoded image in case of storing a processed or re-encoded image.

image Image​Container?

Non-nil in case storing an encoded image.

request Image​Request

The request for which image is being stored.

completion @escaping (Data?) -> Void

The implementation must call the completion closure passing non-nil data to enable caching or nil to prevent it. You can safely call it synchronously. The callback gets called on the background thread.

pipeline(_:​image​Task:​did​Receive​Event:​)

func pipeline(_ pipeline: ImagePipeline, imageTask: ImageTask, didReceiveEvent event: ImageTaskEvent) 

Delivers the events produced by the image tasks started via loadImage method.