ValueAssistant
@MainActor
public protocol ValueAssistant<TargetType>
This protocol defines methods and properties that must be adopted for any value assistant.
-
Undocumented
Declaration
Swift
associatedtype TargetType : AnyObject -
This method generates and returns an array of
PropertyDatainstances based on the providedMotionStateobject.Declaration
Swift
@MainActor func generateProperties<StateType>(targetObject target: TargetType, state: MotionState<TargetType, StateType>) throws -> [PropertyData<TargetType>]Parameters
targetObjectThe root object of the key path which targets the state object.
stateRepresents an object state and associated metadata from which this method should build
PropertyDataobjects.Return Value
An array of
PropertyDatainstances representing the state values of the provided object. -
This method updates a group of properties who have the same parent object.
Declaration
Swift
@MainActor func update(properties: [PropertyData<TargetType> : Double], targetObject: TargetType)Parameters
propertiesA dictionary of updated property values whose keys are
PropertyDataobjects whose property should be updated.targetObjectThe target object.
Return Value
An updated version of the property value, if the object property was found and is supported.
-
Verifies whether this class can update the specified object type.
Declaration
Swift
@MainActor func supports(_ object: Any) -> BoolParameters
objectAn object to verify support for.
Return Value
A Boolean value representing whether the object is supported by this class.
-
Verifies whether this object can accept a keyPath.
Declaration
Swift
@MainActor func acceptsKeypath(_ object: AnyObject) -> BoolParameters
objectAn object to verify support for.
Return Value
A Boolean value representing whether the object is supported by this class.
-
A Boolean which determines whether to update a value using additive updates. When the value is
true, values passed in toupdateValueare added to the existing value instead of replacing it. The default isfalse.Seealso
additiveWeightingDeclaration
Swift
@MainActor var isAdditive: Bool { get set } -
A weighting between 0.0 and 1.0 which is applied to a value updates when the ValueAssistant is updating additively. The higher the weighting amount, the more that a new value will be applied in the
updateValuemethod. A value of 1.0 will apply the full value to the existing value, and a value of 0.0 will apply nothing to it.Note
This value only has an effect whenadditiveis set totrue. The default value is 1.0.Seealso
additiveDeclaration
Swift
@MainActor var additiveWeighting: Double { get set } -
applyAdditiveTo(value:Extension methodnewValue: ) Applies a new
BinaryFloatingPointvalue to an existing one and returns it, either adding to it ifadditivemode is active, or simply replacing it.Declaration
Swift
@MainActor func applyAdditiveTo<ValueType>(value: ValueType, newValue: ValueType) -> ValueType where ValueType : BinaryFloatingPointParameters
valueThe value to modify.
newValueThe value used to modify the existing value.
Return Value
The updated value.
-
applyAdditiveTo(value:Extension methodnewValue: ) Applies a new
BinaryIntegervalue to an existing value and returns it, either adding to it ifadditivemode is active, or simply replacing it.Declaration
Swift
@MainActor func applyAdditiveTo<ValueType>(value: inout ValueType, newValue: ValueType) -> ValueType where ValueType : BinaryIntegerParameters
valueThe value to modify.
newValueThe value used to modify the existing value.
Return Value
The updated value.
View on GitHub