@@ -311,11 +311,11 @@ public struct FetchKey<Value: Sendable>: SharedReaderKey {
311311 continuation. resumeReturningInitialValue ( )
312312 return
313313 }
314- guard !isTesting else {
315- continuation. resume ( with: Result { try database. read ( request. fetch) } )
316- return
317- }
318- let scheduler : any ValueObservationScheduler = scheduler ?? . async ( onQueue : . main )
314+ // guard !isTesting else {
315+ // continuation.resume(with: Result { try database.read(request.fetch) })
316+ // return
317+ // }
318+ let scheduler : any ValueObservationScheduler = scheduler ?? TestImmediateScheduler ( )
319319 database. asyncRead { dbResult in
320320 let result = dbResult. flatMap { db in
321321 Result {
@@ -345,12 +345,7 @@ public struct FetchKey<Value: Sendable>: SharedReaderKey {
345345 Result { try request. fetch ( db) }
346346 }
347347
348- let scheduler : any ValueObservationScheduler
349- if isTesting {
350- scheduler = TestImmediateScheduler ( )
351- } else {
352- scheduler = self . scheduler ?? . async( onQueue: . main)
353- }
348+ let scheduler = self . scheduler ?? TestImmediateScheduler ( )
354349 #if canImport(Combine)
355350 let dropFirst =
356351 switch context {
@@ -439,14 +434,6 @@ public struct NotFound: Error {
439434package struct TestImmediateScheduler : ValueObservationScheduler , Hashable {
440435 package func immediateInitialValue( ) -> Bool { true }
441436 package func schedule( _ action: @escaping @Sendable ( ) -> Void ) {
442- if Thread . isMainThread {
443- DispatchQueue . main. sync {
444- action ( )
445- }
446- } else {
447- DispatchQueue . main. async {
448- action ( )
449- }
450- }
437+ action ( )
451438 }
452439}
0 commit comments