ACKReactiveExtensions icon indicating copy to clipboard operation
ACKReactiveExtensions copied to clipboard

Make `reactive.imageURL` optional

Open olejnjak opened this issue 7 years ago • 0 comments

Use case

When adding images to UIImageView using AlamofireImage, the binding target extension should be of type BindingTarget<URL?> for simple reason. If new imageURL is set AlamofireImage automatically cancels running request for previous URL (if any). But if new model has no imageURL, then imageView.af_cancelImageRequest() should be called to cancel current image request (if any).

Possible solution

There are two possible solutions:

  1. Add imageView.reactive.cancelImageRequest: BindingTarget<Void> and call it if nil is assigned
  2. make imageView.reactive.imageURL of type BindingTarget<URL?> and if nil then imageView.af_cancelImageRequest() will be called

I'd prefer the 2nd solution as it fits our needs best.

https://github.com/AckeeCZ/ACKReactiveExtensions/blob/145af295341226f41202450314129a08c8d80f2a/ACKReactiveExtensions/AlamofireImage/AlamofireImageExtensions.swift#L14

olejnjak avatar Oct 08 '18 12:10 olejnjak