mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Documentation
This commit is contained in:
1 parent
5b9ae9371b
commit
4f8b681737
2 files changed
+17
-7
No files matched your search
@@ -135,9 +135,7 @@ extension ValueObservation where Reducer == ValueReducers.Auto {
|
||||
_ fetch: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{
|
||||
ValueObservation<ValueReducers.Fetch<Value>>(makeReducer: {
|
||||
ValueReducers.Fetch(isSelectedRegionDeterministic: true, fetch: fetch)
|
||||
})
|
||||
.init(makeReducer: { .init(isSelectedRegionDeterministic: true, fetch: fetch) })
|
||||
}
|
||||
|
||||
/// Creates a ValueObservation which notifies the values returned by the
|
||||
@@ -149,8 +147,6 @@ extension ValueObservation where Reducer == ValueReducers.Auto {
|
||||
_ fetch: @escaping (Database) throws -> Value)
|
||||
-> ValueObservation<ValueReducers.Fetch<Value>>
|
||||
{
|
||||
ValueObservation<ValueReducers.Fetch<Value>>(makeReducer: {
|
||||
ValueReducers.Fetch(isSelectedRegionDeterministic: false, fetch: fetch)
|
||||
})
|
||||
.init(makeReducer: { .init(isSelectedRegionDeterministic: false, fetch: fetch) })
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,27 @@
|
||||
extension ValueReducers {
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
///
|
||||
/// A reducer which pass raw fetched values through.
|
||||
/// A reducer which passes raw fetched values through.
|
||||
///
|
||||
/// :nodoc:
|
||||
public struct Fetch<Value>: _ValueReducer {
|
||||
private let _fetch: (Database) throws -> Value
|
||||
public let isSelectedRegionDeterministic: Bool
|
||||
|
||||
/// Creates a ValueReducers.Fetch reducer, which passes raw fetched
|
||||
/// values through.
|
||||
///
|
||||
/// - parameter isSelectedRegionDeterministic: When true, the fetching
|
||||
/// function is assumed to always fetch from the same database region.
|
||||
/// This information is used by ValueObserver, which can optimize the
|
||||
/// observation by computing the observed region only once, and
|
||||
/// performing concurrent fetches of fresh values.
|
||||
///
|
||||
/// When false, the ValueObserver always fetches fresh values from the
|
||||
/// writer dispatch queue, and updates its observed region on
|
||||
/// each fetch.
|
||||
///
|
||||
/// - parameter fetch: A function that fetches the observed value.
|
||||
public init(isSelectedRegionDeterministic: Bool, fetch: @escaping (Database) throws -> Value) {
|
||||
self.isSelectedRegionDeterministic = isSelectedRegionDeterministic
|
||||
self._fetch = fetch
|
||||
|
||||
Reference in new issue
Block a user