_ValueReducer

public protocol _ValueReducer

Experimental

The _ValueReducer protocol supports ValueObservation.

  • The type of fetched database values

    Declaration

    Swift

    associatedtype Fetched
  • The type of observed values

    Declaration

    Swift

    associatedtype Value
  • Returns whether the database region selected by the fetch(_:) method is constant.

    Declaration

    Swift

    var isSelectedRegionDeterministic: Bool { get }
  • Fetches database values upon changes in an observed database region.

    _ValueReducer semantics require that this method does not depend on the state of the reducer.

    Declaration

    Swift

    func fetch(_ db: Database) throws -> Fetched
  • Transforms a fetched value into an eventual observed value. Returns nil when observer should not be notified.

    This method runs in some unspecified dispatch queue.

    _ValueReducer semantics require that the first invocation of this method returns a non-nil value:

    let reducer = MyReducer()
    reducer.value(...) // MUST NOT be nil
    reducer.value(...) // MAY be nil
    reducer.value(...) // MAY be nil
    

    Declaration

    Swift

    mutating func value(_ fetched: Fetched) -> Value?