From dfa40ea18f8b9fe359f57c8660c5af526e2ba322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 12 Mar 2020 07:34:43 +0100 Subject: [PATCH] Rename ValueObservation.fetchFirst to fetchValue "First", in Swift, hints that the result is optional. But the result of this function is no longer optional. --- GRDB/Core/DatabaseSnapshot.swift | 8 ++++---- GRDB/ValueObservation/ValueObservation.swift | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GRDB/Core/DatabaseSnapshot.swift b/GRDB/Core/DatabaseSnapshot.swift index d3c3ae5d6..5e066713f 100644 --- a/GRDB/Core/DatabaseSnapshot.swift +++ b/GRDB/Core/DatabaseSnapshot.swift @@ -126,13 +126,13 @@ extension DatabaseSnapshot { case .mainQueue: if DispatchQueue.isMain { do { - try onChange(read(observation.fetchFirst)) + try onChange(serializedDatabase.reentrantSync(observation.fetchValue)) } catch { onError(error) } } else { serializedDatabase.async { db in - let result = Result { try observation.fetchFirst(db) } + let result = Result { try observation.fetchValue(db) } DispatchQueue.main.async { do { try onChange(result.get()) @@ -144,7 +144,7 @@ extension DatabaseSnapshot { } case let .async(onQueue: queue): serializedDatabase.async { db in - let result = Result { try observation.fetchFirst(db) } + let result = Result { try observation.fetchValue(db) } queue.async { do { try onChange(result.get()) @@ -155,7 +155,7 @@ extension DatabaseSnapshot { } case .unsafe: do { - try onChange(unsafeReentrantRead(observation.fetchFirst)) + try onChange(serializedDatabase.reentrantSync(observation.fetchValue)) } catch { onError(error) } diff --git a/GRDB/ValueObservation/ValueObservation.swift b/GRDB/ValueObservation/ValueObservation.swift index f0d9eb846..0adfb9bf1 100644 --- a/GRDB/ValueObservation/ValueObservation.swift +++ b/GRDB/ValueObservation/ValueObservation.swift @@ -123,8 +123,8 @@ extension ValueObservation { // TODO: make public if it helps fetching an initial value before starting // the observation, in order to avoid waiting for long write transactions to // complete. - /// Returns the observed value. - func fetchFirst(_ db: Database) throws -> Reducer.Value { + /// Returns the value. + func fetchValue(_ db: Database) throws -> Reducer.Value { var reducer = makeReducer() let fetchedValue = try reducer.fetch(db, requiringWriteAccess: requiresWriteAccess) guard let value = reducer.value(fetchedValue) else {