Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Created June 7, 2019 20:23
Show Gist options
  • Select an option

  • Save dmytro-anokhin/5e833975ecde1ed8beafa815e3a0808a to your computer and use it in GitHub Desktop.

Select an option

Save dmytro-anokhin/5e833975ecde1ed8beafa815e3a0808a to your computer and use it in GitHub Desktop.
struct URLImage : View {
// ...
var body: some View {
if let image = imageLoader.image {
return image
.onAppear {}
.onDisappear {}
}
else {
return placeholder
.onAppear {
self.imageLoader.load()
}
.onDisappear {
self.imageLoader.cancel()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment