Skip to content

Instantly share code, notes, and snippets.

@keremk
Last active January 12, 2020 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keremk/3226fb9317010b706b828ba65182e93d to your computer and use it in GitHub Desktop.
Save keremk/3226fb9317010b706b828ba65182e93d to your computer and use it in GitHub Desktop.
final class ImageResolver: ObservableObject {
@Published var image: CGImage? = nil
...
func fetchImage() -> CGImage? {
return fetchPreviewImage(imageName: name, size: size, fetcher: fetch)
}
private func fetch() -> CGImage? {
if image != nil {
return image
}
imageFetchable.fetchImage(name: name, size: size)
.sink( ... )
.store(...)
return image
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment