mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-29 04:24:21 +00:00
TODO: remove some magic in GRDB 4
This commit is contained in:
1 parent
c711ca1e8f
commit
88d7c58522
4 files changed
+8
No files matched your search
@@ -28,6 +28,7 @@ extension ValueObservation where Reducer == Void {
|
||||
public static func trackingCount<Request: FetchRequest>(_ request: Request)
|
||||
-> ValueObservation<DistinctUntilChangedValueReducer<RawValueReducer<Int>>>
|
||||
{
|
||||
// TODO: Remove distinctUntilChanged in GRDB 4
|
||||
return ValueObservation.tracking(request, fetch: request.fetchCount).distinctUntilChanged()
|
||||
}
|
||||
}
|
||||
@@ -124,6 +124,7 @@ public struct DatabaseValuesReducer<Request: FetchRequest>: ValueReducer
|
||||
public mutating func value(_ dbValues: [DatabaseValue]) -> [Request.RowDecoder]? {
|
||||
if let previousDbValues = previousDbValues, previousDbValues == dbValues {
|
||||
// Don't notify consecutive identical dbValue arrays
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
}
|
||||
self.previousDbValues = dbValues
|
||||
@@ -157,6 +158,7 @@ public struct DatabaseValueReducer<Request: FetchRequest>: ValueReducer
|
||||
public mutating func value(_ dbValue: DatabaseValue?) -> Request.RowDecoder?? {
|
||||
if let previousDbValue = previousDbValue, previousDbValue == dbValue {
|
||||
// Don't notify consecutive identical dbValue
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
}
|
||||
self.previousDbValue = dbValue
|
||||
@@ -167,6 +169,7 @@ public struct DatabaseValueReducer<Request: FetchRequest>: ValueReducer
|
||||
return .some(value)
|
||||
} else if previousValueWasNil {
|
||||
// Don't notify consecutive nil values
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
} else {
|
||||
previousValueWasNil = true
|
||||
@@ -200,6 +203,7 @@ public struct OptionalDatabaseValuesReducer<Request: FetchRequest>: ValueReducer
|
||||
public mutating func value(_ dbValues: [DatabaseValue]) -> [Request.RowDecoder._Wrapped?]? {
|
||||
if let previousDbValues = previousDbValues, previousDbValues == dbValues {
|
||||
// Don't notify consecutive identical dbValue arrays
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
}
|
||||
self.previousDbValues = dbValues
|
||||
|
||||
@@ -91,6 +91,7 @@ public struct FetchableRecordsReducer<Request: FetchRequest>: ValueReducer
|
||||
public mutating func value(_ rows: [Row]) -> [Request.RowDecoder]? {
|
||||
if let previousRows = previousRows, previousRows == rows {
|
||||
// Don't notify consecutive identical row arrays
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
}
|
||||
self.previousRows = rows
|
||||
@@ -121,6 +122,7 @@ public struct FetchableRecordReducer<Request: FetchRequest>: ValueReducer
|
||||
public mutating func value(_ row: Row?) -> Request.RowDecoder?? {
|
||||
if let previousRow = previousRow, previousRow == row {
|
||||
// Don't notify consecutive identical rows
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
}
|
||||
self.previousRow = row
|
||||
|
||||
@@ -120,6 +120,7 @@ public struct RowReducer<Request: FetchRequest>: ValueReducer
|
||||
public mutating func value(_ row: Row?) -> Row?? {
|
||||
if let previousRow = previousRow, previousRow == row {
|
||||
// Don't notify consecutive identical rows
|
||||
// TODO: Remove this implicit `distinctUntilChanged` in GRDB 4
|
||||
return nil
|
||||
}
|
||||
self.previousRow = row
|
||||
|
||||
Reference in new issue
Block a user