@@ -117,36 +117,39 @@ public actor PersistentContainerStorage: ModelStorage, ObservableObject {
117117 }
118118 }
119119
120+ public func fetchID( _ fetchRequest: FetchRequest ) async throws -> [ ObjectID ] {
121+ return try await performBackgroundTask { ( context, model) in
122+ try context. fetchID ( fetchRequest)
123+ }
124+ }
125+
120126 public func count( _ fetchRequest: FetchRequest ) async throws -> UInt {
121127 try await performBackgroundTask { ( context, model) in
122128 try context. count ( fetchRequest)
123129 }
124130 }
125131
126132 public func insert( _ value: ModelData ) async throws {
133+ defer { objectWillChange. send ( ) }
127134 try await performBackgroundTask { ( context, model) in
128135 try context. insert ( value, model: model)
129136 }
130137 }
131138
132139 public func insert( _ values: [ ModelData ] ) async throws {
140+ defer { objectWillChange. send ( ) }
133141 try await performBackgroundTask { ( context, model) in
134142 try context. insert ( values, model: model)
135143 }
136144 }
137145
138146 public func delete( _ entity: EntityName , for id: ObjectID ) async throws {
147+ defer { objectWillChange. send ( ) }
139148 try await performBackgroundTask { ( context, model) in
140149 try context. delete ( entity, for: id)
141150 }
142151 }
143152
144- public func fetchID( _ fetchRequest: FetchRequest ) async throws -> [ ObjectID ] {
145- try await performBackgroundTask { ( context, model) in
146- try context. fetchID ( fetchRequest)
147- }
148- }
149-
150153 private func performBackgroundTask< T> (
151154 schedule: NSManagedObjectContext . ScheduledTaskType = . immediate,
152155 _ task: @escaping ( NSManagedObjectContext , NSManagedObjectModel ) throws -> T
0 commit comments