func identity<T>(value: T) -> T { | |
return value | |
} | |
extension UIImageView { | |
func composable_setResizedImage(processUrl proccessUrl: (NSURL -> NSURL) = identity, processImage: (UIImage -> UIImage) = identity) -> NSURL -> Void { | |
return { url in | |
let processedURL = proccessUrl(url) | |
let request = requestForImageUrl(processedURL) | |
fetchData(request) { data in | |
guard let image = imageFromResponseData(data) else { | |
return | |
} | |
let processedImage = processImage(image) | |
dispatch_async(dispatch_get_main_queue(), { | |
applyImage(processedImage, to: self) | |
}) | |
} | |
} | |
} | |
func downloadAndResizeLocally(url: NSURL) { | |
let download = composable_setResizedImage(processImage: resizeImage(to: frame.size)) | |
download(url) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment