MainViewModel documentation and image caching improvements

This commit is contained in:
Vicnet
2023-09-16 20:11:02 +02:00
parent fd2c67809a
commit 3504ce2a25
9 changed files with 166 additions and 71 deletions

View File

@@ -63,6 +63,6 @@ struct RecipeDetail: Codable {
}
struct RecipeImage {
let thumb: UIImage
let full: UIImage?
var thumb: UIImage?
var full: UIImage?
}

View File

@@ -32,13 +32,17 @@ class DataStore {
return try await task.value
}
func save<D: Encodable>(data: D, toPath path: String) async throws {
func save<D: Encodable>(data: D, toPath path: String) async {
let task = Task {
let data = try JSONEncoder().encode(data)
let outfile = try Self.fileURL(appending: path)
try data.write(to: outfile)
}
_ = try await task.value
do {
_ = try await task.value
} catch {
print("Could not save data (path: \(path)")
}
}
func clearAll() {