StateChangeEvent

struct StateChangeEvent<T> where T : Trait

A state change event for a given trait.

  • The type ID of the trait that changed.

    Declaration

    Swift

    let typeID: String
  • The previous value of the trait, if any.

    Declaration

    Swift

    let oldValue: T?
  • The new value of the trait.

    Declaration

    Swift

    let newValue: T
  • Computes strongly-typed changes for a specific property.

    Returns nil if the property did not change, or if there is no previous state and ignoreNilOldValue is true.

    Declaration

    Swift

    func change<Value>(for keyPath: KeyPath<T, Value>, ignoreNilOldValue: Bool = false) -> ValueChange<Value>? where Value : Equatable, Value : Sendable

    Parameters

    ignoreNilOldValue

    If true, returns nil when there is no previous state to compare against.

    Return Value

    A ValueChange if the property changed, otherwise nil.