diff --git a/README.md b/README.md
index 15a7c83..75d4535 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
# 📩 Loadability
### Powerful, modern networking and caching with SwiftUI support
+#### v1.0.5
-**This package has changed since the documentation was updated to support newer language features. To support older versions of operating systems, see the [deprecated branch](https://github.com/julianschiavo/Loadability/tree/deprecated).**
+**This package has changed since the documentation was updated to add support for newer language features (async/await). To support older versions of operating systems, see the [deprecated branch](https://github.com/julianschiavo/Loadability/tree/deprecated).**
diff --git a/Sources/Loadability/Networking/CachedLoader.swift b/Sources/Loadability/Networking/CachedLoader.swift
index b11ca73..dbd6f6e 100644
--- a/Sources/Loadability/Networking/CachedLoader.swift
+++ b/Sources/Loadability/Networking/CachedLoader.swift
@@ -40,7 +40,7 @@ public extension CachedLoader {
func refresh(key: Key) async {
guard task == nil else { return }
- cancel()
+ await cancel()
try? await cache.removeValue(for: key)
object = nil
// await load(key: key)
diff --git a/Sources/Loadability/Networking/Loader.swift b/Sources/Loadability/Networking/Loader.swift
index 747d3f1..f18ffc8 100644
--- a/Sources/Loadability/Networking/Loader.swift
+++ b/Sources/Loadability/Networking/Loader.swift
@@ -43,10 +43,10 @@ public protocol Loader: ObservableObject, ThrowsErrors {
/// - Parameters:
/// - key: The key identifying the object that was loaded.
/// - object: The loaded object.
- func loadCompleted(key: Key, object: Object)
+ func loadCompleted(key: Key, object: Object) async
/// Cancels the current loading operation.
- func cancel()
+ func cancel() async
}
public extension Loader {
@@ -54,7 +54,7 @@ public extension Loader {
let task = Task { () -> Object in
let object = try await loadData(key: key)
self.object = object
- loadCompleted(key: key, object: object)
+ await loadCompleted(key: key, object: object)
return object
}
self.task = task
@@ -71,7 +71,7 @@ public extension Loader {
func refresh(key: Key) async {
guard task == nil else { return }
- cancel()
+ await cancel()
object = nil
await load(key: key)
}
@@ -103,12 +103,12 @@ public extension Loader {
return nil
}
- func loadCompleted(key: Key, object: Object) {
+ func loadCompleted(key: Key, object: Object) async {
// Default implementation does nothing. This is used by the more advanced loaders to allow for inserting cache events.
}
/// Cancels the ongoing load.
- func cancel() {
+ func cancel() async {
task?.cancel()
task = nil
diff --git a/Sources/Loadability/Networking/SimpleNetworkLoader.swift b/Sources/Loadability/Networking/SimpleNetworkLoader.swift
index d01709e..fac3c06 100644
--- a/Sources/Loadability/Networking/SimpleNetworkLoader.swift
+++ b/Sources/Loadability/Networking/SimpleNetworkLoader.swift
@@ -5,7 +5,7 @@ import Foundation
public protocol SimpleNetworkLoader: Loader {
/// Creates a `URLRequest` for a network loading request.
/// - Parameter key: The key identifying the object to load.
- func createRequest(for key: Key) -> URLRequest
+ func createRequest(for key: Key) async -> URLRequest
/// Decodes data received from a network request into the object.
/// - Parameters:
@@ -16,7 +16,7 @@ public protocol SimpleNetworkLoader: Loader {
public extension SimpleNetworkLoader {
func loadData(key: Key) async throws -> Object {
- let request = createRequest(for: key)
+ let request = await createRequest(for: key)
let (data, _) = try await URLSession.shared.data(for: request)
return try await self.decode(data, key: key)
}
diff --git a/Sources/Loadability/UI/Load.swift b/Sources/Loadability/UI/Load.swift
index 83cc214..f9d119d 100644
--- a/Sources/Loadability/UI/Load.swift
+++ b/Sources/Loadability/UI/Load.swift
@@ -66,7 +66,9 @@ public struct Load