mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
Rename ValueObservation.fetchFirst to fetchValue
"First", in Swift, hints that the result is optional. But the result of this function is no longer optional.
This commit is contained in:
1 parent
936c92eba6
commit
dfa40ea18f
2 files changed
+6
-6
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user