Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active August 20, 2022 03:02
Show Gist options
  • Save laevandus/0cff5687df5a5b7bd49fd43a41b8ac42 to your computer and use it in GitHub Desktop.
Save laevandus/0cff5687df5a5b7bd49fd43a41b8ac42 to your computer and use it in GitHub Desktop.
@MainActor final class ViewModel: ObservableObject {
func prepare() {
Task {
do {
async let wallpaperData = service.fetchImageData(id: "blue_wallpaper")
async let overlayData = service.fetchImageData(id: "gradient_overlay")
self.backgroundImage = try await ImageProcessor.merge(background: wallpaperData, overlay: overlayData)
} catch {
// TODO: present/handle error
}
}
}
}
struct ImageProcessor {
static func merge(background: Data, overlay: Data) throws -> UIImage {
// …
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment