We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1ee1d20 commit 5c7cbe0Copy full SHA for 5c7cbe0
1 file changed
Sources/CoreDataRepository/CoreDataRepository+Fetch.swift
@@ -55,4 +55,14 @@ extension CoreDataRepository {
55
subscription.manualFetch()
56
}
57
58
+
59
+ /// Fetch items from the store with a ``NSFetchRequest`` and transform the results.
60
+ public func fetch<Managed, Output>(
61
+ request: NSFetchRequest<Managed>,
62
+ operation: @escaping (_ results: [Managed]) throws -> Output
63
+ ) async -> Result<Output, CoreDataError> where Managed: NSManagedObject {
64
+ await context.performInChild { fetchContext in
65
+ try operation(fetchContext.fetch(request))
66
+ }
67
68
0 commit comments