mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Rename tracking(value:) to tracking(_:)
This commit is contained in:
1 parent
9792edc008
commit
294a04e9f6
6 files changed
+19
-17
No files matched your search
@@ -211,19 +211,25 @@ extension ValueObservation where Reducer == Never {
|
||||
where Request.RowDecoder == Row
|
||||
{ preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, message: "Use ValueObservation.tracking(value:) instead")
|
||||
@available(*, unavailable, message: "Use ValueObservation.tracking(_:) instead")
|
||||
public static func tracking<Value>(
|
||||
_ regions: DatabaseRegionConvertible...,
|
||||
fetch: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{ preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, message: "Use ValueObservation.tracking(value:) instead")
|
||||
@available(*, unavailable, message: "Use ValueObservation.tracking(_:) instead")
|
||||
public static func tracking<Value>(
|
||||
_ regions: [DatabaseRegionConvertible],
|
||||
fetch: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{ preconditionFailure() }
|
||||
|
||||
@available(*, unavailable, renamed: "tracking(_:)")
|
||||
public static func tracking<Value>(
|
||||
value: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{ preconditionFailure() }
|
||||
}
|
||||
|
||||
extension ValueObservation where Reducer.Value: Equatable {
|
||||
|
||||
@@ -30,9 +30,7 @@ extension FetchRequest {
|
||||
public func observationForCount() ->
|
||||
ValueObservation<ValueReducers.RemoveDuplicates<ValueReducers.Fetch<Int>>>
|
||||
{
|
||||
return ValueObservation
|
||||
.tracking(value: fetchCount)
|
||||
.removeDuplicates()
|
||||
ValueObservation.tracking(fetchCount).removeDuplicates()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ extension ValueObservation where Reducer == Never {
|
||||
/// - parameter value: A function that fetches the observed value from
|
||||
/// the database.
|
||||
public static func tracking<Value>(
|
||||
value: @escaping (Database) throws -> Value)
|
||||
_ value: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{
|
||||
return ValueObservation<ValueReducers.Fetch<Value>>(makeReducer: {
|
||||
@@ -176,7 +176,7 @@ extension ValueObservation where Reducer == Never {
|
||||
/// - parameter value: A function that fetches the observed value from
|
||||
/// the database.
|
||||
public static func trackingVaryingRegion<Value>(
|
||||
value: @escaping (Database) throws -> Value)
|
||||
_ value: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{
|
||||
return ValueObservation<ValueReducers.Fetch<Value>>(makeReducer: {
|
||||
|
||||
@@ -72,8 +72,8 @@ public enum ValueReducers { }
|
||||
// TODO: define an empty NeverReducer enum instead of reusing Never.
|
||||
// This allows us to use Never as a marker for ValueObservation factory methods:
|
||||
//
|
||||
// For example, ValueObservation.tracking(value:) is, practically,
|
||||
// ValueObservation<Never>.tracking(value:).
|
||||
// For example, ValueObservation.tracking(_:) is, practically,
|
||||
// ValueObservation<Never>.tracking(_:).
|
||||
extension Never: _ValueReducer {
|
||||
public var isObservedRegionDeterministic: Bool { preconditionFailure() }
|
||||
public func fetch(_ db: Database) throws -> Never { preconditionFailure() }
|
||||
|
||||
@@ -5505,7 +5505,7 @@ Tracked changes include changes performed by the [query interface](#the-query-in
|
||||
}
|
||||
|
||||
// The same observation, with short-hand notation:
|
||||
let observation = ValueObservation.tracking(value: Player.fetchAll)
|
||||
let observation = ValueObservation.tracking(Player.fetchAll)
|
||||
```
|
||||
|
||||
The observation can perform multiple requests, from multiple database tables, and even use raw SQL.
|
||||
@@ -5556,7 +5556,7 @@ import Combine
|
||||
import GRDB
|
||||
import GRDBCombine
|
||||
|
||||
let observation = ValueObservation.tracking(value: Player.fetchAll)
|
||||
let observation = ValueObservation.tracking(Player.fetchAll)
|
||||
|
||||
let cancellable = observation.publisher(in: dbQueue).sink(
|
||||
receiveCompletion: { completion in ... },
|
||||
@@ -5575,7 +5575,7 @@ import GRDB
|
||||
import RxGRDB
|
||||
import RxSwift
|
||||
|
||||
let observation = ValueObservation.tracking(value: Player.fetchAll)
|
||||
let observation = ValueObservation.tracking(Player.fetchAll)
|
||||
|
||||
let disposable = observation.rx.changes(in: dbQueue).subscribe(
|
||||
onNext: { (players: [Player]) in
|
||||
@@ -5786,7 +5786,7 @@ When needed, you can help GRDB optimize observations and reduce database content
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
// Start observing the database
|
||||
let observation = ValueObservation.tracking(value: Player.fetchAll)
|
||||
let observation = ValueObservation.tracking(Player.fetchAll)
|
||||
observer = observation.start(
|
||||
in: dbQueue,
|
||||
onError: { error in ... },
|
||||
@@ -5820,7 +5820,7 @@ When needed, you can help GRDB optimize observations and reduce database content
|
||||
import RxGRDB
|
||||
import RxSwift
|
||||
|
||||
let observation = ValueObservation.tracking(value: Player.fetchAll)
|
||||
let observation = ValueObservation.tracking(Player.fetchAll)
|
||||
let observable = observation.rx
|
||||
.changes(in: dbQueue)
|
||||
.share(replay: 1, scope: .whileConnected)
|
||||
@@ -5832,7 +5832,7 @@ When needed, you can help GRDB optimize observations and reduce database content
|
||||
|
||||
```swift
|
||||
// Plain observation
|
||||
let observation = ValueObservation.tracking(value: Player.fetchAll)
|
||||
let observation = ValueObservation.tracking(Player.fetchAll)
|
||||
|
||||
// Optimized observation
|
||||
let observation = ValueObservation.tracking(Player.all(), fetch: Player.fetchAll)
|
||||
|
||||
@@ -53,8 +53,6 @@
|
||||
- [ ] https://forums.swift.org/t/how-to-encode-objects-of-unknown-type/12253/6
|
||||
- [ ] Configuration.crashOnError = true
|
||||
- [ ] Glossary (Database Access Methods, etc.)
|
||||
- [ ] ValueObservation.flatMap. Not sure it is still useful now that we have ValueObservation.tracking(value:)
|
||||
- [ ] rename fetchOne to fetchFirst. Not sure because it is a big breaking change. Not sure because ValueObservation.tracking(value:) has reduced the need for observationForFirst.
|
||||
- [ ] Not sure: type safety for SQL expressions
|
||||
- [ ] Introduce some record protocol with an associated primary key type. Restrict filter(key:) methods to this type. Allow distinguishing FooId from BarId types.
|
||||
- [ ] Replace Column with TypedColumn. How to avoid code duplication (repeated types)? Keypaths?
|
||||
|
||||
Reference in new issue
Block a user