MeasurementProperty

@propertyWrapper
public final class MeasurementProperty<Unit> : UpdatableProperty, Equatable where Unit : Unit
  • Declaration

    Swift

    public typealias Value = Measurement<Unit>
  • Declaration

    Swift

    public static func == (lhs: MeasurementProperty<Unit>, rhs: MeasurementProperty<Unit>) -> Bool
  • Declaration

    Swift

    public var wrappedValue: Value { get set }
  • Declaration

    Swift

    public var projectedValue: ReadOnlyProperty<MeasurementProperty<Unit>> { get }

Property Requirements

  • The latest snapshot of data.

    Declaration

    Swift

    @Published
    public internal(set) var snapshot: Snapshot<Value> { get set }
  • A human-friendly display name that describes the property.

    Declaration

    Swift

    public let displayName: String
  • A formatter that can be used to build a human-friendly string from the value.

    Declaration

    Swift

    public let formatter: MeasurementFormatter
  • Declaration

    Swift

    public var snapshotsPublisher: AnyPublisher<Snapshot<Value>, Never> { get }

Measurement Properties

  • Declaration

    Swift

    public var measurement: Measurement<Unit> { get }
  • Declaration

    Swift

    public var unit: Unit { get }
  • Declaration

    Swift

    public var measuredValue: Double { get }

Initialisers

Update Functions

  • Declaration

    Swift

    @discardableResult
    public func updateValue(
        _ value: Measurement<Unit>,
        date: Date
    ) -> Snapshot<Value>
  • Declaration

    Swift

    @discardableResult
    public func updateMeasuredValue(
        _ measuredValue: Double,
        date: Date = Date()
    ) -> Snapshot<Value>
  • Updates the value backing this Property, only if the provided value is different.

    Declaration

    Swift

    @discardableResult
    public func updateMeasuredValueIfDifferent(_ measuredValue: Double, date: Date = Date()) -> Snapshot<Value>?

    Parameters

    value

    The new value.

    date

    The date and time the value was recorded. Defaults to the current date and time.

    Return Value

    The new snapshot, or nil if the value was not different.